What is the best way to reuse code between controller and command? I have some use where the very same logic should be executed inside controller and in command as well. What is the best approach to share code? To create a component and the call this component methods from controller and command?
Asked
Active
Viewed 155 times
1 Answers
1
Create a class (model, service, etc), and use that in the different areas.
Within the config/main.php
or config/console.php
there is an import section:
'import' => array(
'application.models.*',
'application.components.*',
You can add your class anywhere really, as long as its location is referenced within the import
section in the config, as that is how Yii1 autoloads files.

Adoni
- 146
- 4