I have been working in yii for the last two months or so. Initially when I started working in it, I thought that it’s an amzing framework, quite easy, flexible and fast. I found my mouth open when I created my first appliction using yiic and I said wohooo, its kinda real fun. But working for sometime things got a bit hard for me. I was unable to understand how to make relationships and then fetch data from related tables, but with the passage of time and after reading the documentation it gave me lots of surprises.
I don’t know what my opinion will be about yii in future, but currently I find it quite helpful and interesting. It will be worth mentioning here that before working in yii, I had worked in different frameworks like Zend Framework, CakePhp and even for some time in RoR. I have nearly two years of Zend Framework experience, and when I was doing my first project in Zend, I was kinda fall in love with it. Many people complain about Zend complaxity but I would recomand it for enterprise level application as it provides nearly everything that a large scale application needs.
This article has nothing to do with the comparsion, its purely about yii introduction and my experience with it, so I m not gonna give pros and cons of the frameworks that I have used so far. Lets leave it for future discussion.
The best thing that come to my mind when I think about yii is its installation. It cannot be simple then this, download yii from http://www.yiiframework.com and extract where you like it to be, like your application root. I suppose you keep it in /var/www/ on linux. Once you extract it open your browser and write as follows for checking system requirements.
http://localhost/yii/requirements/
Your system must pass certain tests like php version should be 5.1.0 or greater etc. if not some of your configuration don’t pass some of yii functionality will not work accordingly.
Once successfully install next step is to create your application, but before devling into the details of how to create your first application, I will suggest you to go through demo application in path/to/yii/demos/. The are no doubt good point to start with.
Once you decide that its time to create your first application, go to terminal/command prompt and execute the following command.
yiic webapp path/to/root/app_name
The above line will create complete directory structure, like all your contorllers, models and views directories etc. The line however may not work in some conditions like
If path to your php.exe is not set(mostly in windows)
You can freely ask your questions if you stuck somewhere. I will be glad to hear you.
Once you successfully created your application, then comes the time to wit your hands with the code and the first place where I will emphesis to make changes is “ your_app/protected/config/main.php” file. Here you can make database configuration; already done, you will need to comment out code that you don’t need, give host, database user and database information(if you like to use mysql instead of postgrase).
There are lots of good things about yii, but the one I would like to mention in this post is “gii”. GUI that give you ability to create controllers, models, view and even CRUD. For “gii” you will need to add the following code in your “path/to/your_app/protected/config/main.php”.
'modules'=>array(
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'12345',
),
),
Now if you write http://localhost/your_app/index.php?r=gii, you will see a page asking you to login. Once loging in you can use “gii” GUI to create controllers, models etc.
Just try yii and let me know whether you find it interesting or not.
Your queries will be welcome.
Oh come on, I know that yii cannot be covered in one page article so lets leave discussion open.
