GImport yii extension

GImport yii extension implements recursive import of directories with caching.

Import is performed recursively for specified path alias. Classes found are cached, so the import process can be slow only first time.

Basic usage example:

    $importer = new GImport;
    $importer->add('modules.myModule.*');

This code will import all clasees from modules/myModule/ directory.

GImport can also be configured as application component. Add following code into the application config:

    return array(
    ...
    'preload' => array('log', 'import'),
    ...
    'components' => array(
        'import' => array(
            'class'=>'GImport',
            'import' => array(
                // add directories to import and
                // put 'import' component to preload to trigger import
                // on application initialization
                'application.extensions.*',
            ),
        ),
    ...

Download at extension page.

Forum topic.

profile for Boris Serebrov on Stack Exchange, a network of free, community-driven Q&A sites