Relative file paths and migrations in Yii1

Watch out for relative file paths. When using them in any action, files lands in a folder (from that relative path) in root directory folder (where they’re is expected, at least according to me). But, when you use the very same path in a migration, then files will land in a folder in protected folder. I have just found this to my surprise.

To “fix” this, you need to add:

[php]dirname(__FILE__).’/../../’.[/php]

in front of your relative path (which makes it no longer relative, though).

Details on Yii forum.

Leave a Reply