thureos
(Luis)
April 18, 2012, 5:40pm
1
Hi everyone,
We’re gonna migrate all our apps to Yii. My colleagues and me have no experience with this framework, but all of us think is the right for us to accomplish this task.
We have a doubt:
How can we make reusable models so all of our apps can use common tables like cities or states without making the same model in every new app we develop.
Thanks in advanced.
Sorry for my english.
redguy
(Maciej Lizewski)
April 18, 2012, 7:43pm
2
you can keep them in separate directory, then create alias for this directory and add it to default search like this:
(config main.php)
Yii::setPathOfAlias( 'common', '/opt/common' );
return array(
'basePath'=>dirname( dirname( __FILE__ ) ),
'name'=>'Yii Application',
'import'=>array(
'application.models.*',
'application.components.*',
'common.*',
'common.subdirectory.*',
),
...
and that’s all. you can reference models simply by using them:
$model = new CommonModel();
thureos
(Luis)
April 18, 2012, 9:11pm
3
redguy:
you can keep them in separate directory, then create alias for this directory and add it to default search like this:
(config main.php)
Yii::setPathOfAlias( 'common', '/opt/common' );
return array(
'basePath'=>dirname( dirname( __FILE__ ) ),
'name'=>'Yii Application',
'import'=>array(
'application.models.*',
'application.components.*',
'common.*',
'common.subdirectory.*',
),
...
and that’s all. you can reference models simply by using them:
$model = new CommonModel();
Red Guy, you’re the man!!
Thanks!