The first question that one is confronted with when using Yii, is how to start a new project . There are some official tutorials like Creating Your First Yii Application
The problem with this approach is you first need to download Yii Framework zip file and, then later, put it under version control. Ideally it is a third party component, so it should be installed as any other PHP library, preferable using Composer.
Normally, when you are using Composer, you would like to put all the packages installed by composer in “protected/vendor” directory. This directory structure is created when “yiic webapp app-name” command. We can issue this command as we don’t have Yii yet. So its a catch-22. How to solve it?
The solution is simple. we decide what the our web-app name should be before-hand. e.g. “app”. Create a main project directory and make a file named composer.json with the following content, in that directory (GIST here)
{ "require":{ "yiisoft/yii":"1.1.16", "yiiext/migrate-command":"0.8.0" }, "config":{ "vendor-dir":"app/protected/vendor/" } }
Then, issue the following command to install Yii. (If you have not installed Composer, you can refer to this link)
php composer.phar install
Once Yii is installed, we can use the following command to generate the Yii web-app
./app/protected/vendor/bin/yiic webapp app
Make sure that name of the web-app is the same as in composer.json. (in our case “app”) Yii will create all the directories and it will reside in “protected/vendor” directory, itself.
Its a good idea to add “app/protected/vendor” directory in version-control ignore list (.svnignore, .gitignore)
One more thing to do is to load protected/vendor/autoload.php. A good place to do it, is in the beginning of “protected/main.php”. Add the following line there
require_once( dirname(__FILE__) . '/../vendor/autoload.php');
And, this is how you compose a new Yii project.