dev-master
9999999-dev https://github.com/MetalGuardian/yii-file-processor
MIT
by Ivan Pushkin
file extension upload module yii
in config/main.php:, (*1)
Yii::setPathOfAlias('fileProcessor', '/path/to/extension/');
example for standard yii structure when this module located in extension dir:, (*2)
Yii::setPathOfAlias('fileProcessor', dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . 'yii-file-processor' . DIRECTORY_SEPARATOR . 'fileProcessor');
application config:, (*3)
... 'controllerMap' => array( 'image' => array( 'class' => '\fileProcessor\controllers\ImageController', ), ), ...
if you merge main config with console config, you need unset controllerMap key, (*4)
modules section:, (*5)
'file-processor' => array( 'baseDir' => realpath( __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'www' ) . DIRECTORY_SEPARATOR, 'imageSections' => array( 'admin' => array( 'default' => array( 'width' => 100, 'height' => 100, 'quality' => 100, 'do' => 'resize', // resize|adaptiveResize ), ), ), 'imageHandler' => array( 'driver' => '\fileProcessor\extensions\imageHandler\drivers\MDriverGD', // '\fileProcessor\extensions\imageHandler\drivers\MDriverImageMagic' ), ),
component section:, (*6)
'urlManager'=>array( ... 'rules'=>array( ... array( 'class' => '\fileProcessor\components\YiiFileProcessorUrlRule', 'connectionId' => 'db', 'cacheId' => 'cache', 'controllerId' => 'image', ), // controllerId - name of the controller, which you set in controller map ... ), ),
add behavior to the model:, (*7)
'fileBehavior' => array( 'class' => '\fileProcessor\components\FileUploadBehavior', 'attributeName' => 'file_id', 'fileTypes' => 'png, gif, jpeg, jpg', ),
Run command:, (*8)
php protected/yiic.php migrate --migrationPath=application.extensions.yii-file-processor.fileProcessor.migrations
MIT
file extension upload module yii