Yii is a very high performance PHP framework used for development of web applications. It’s free and open-source framework which follows MVC architecture.So now you might be thinking that there is many other PHP MVC framework like Laravel, Symfony, Cake, Codeigniter etc. are available why i use yii framework.The best thing about Yii’s is it’s performance. Definitely If you are making highly-scalable web application then you can’t ignore this point.
Check Yii performance with other frameworks.
Important Features of Yii Framework
1. Model-View-Controller (MVC) design pattern.
2. Database Access Objects (DAO), Query Builder, Active Record, DB Migration.
3. Authentication and authorization.
4. Form input and validation.
5. Web services.
6. Error handling and logging.
7. Security.
There are lot of features Yii framework offers. Check complete features and their descriptions.
How to Install and Setup Yii Framework
To install Yii framework, i assume you have LAMP setup and installed in your system.
Download Yii Framework. Extract the zip file in webroot.
After extracting zip ,let’s move to yii folder and navigate to project root directory. Now i am going to use yiic command line tool to create new project.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
// Generate first application code through yiic // This command create new directory with the name firstapp. php yiic webapp ../firstapp or yiic webapp ../firstapp Create a Web application under '/var/www/learn/yii/firstapp'? (yes|no) [no]: mkdir /var/www/learn/yii/firstapp generate index-test.php mkdir /var/www/learn/yii/firstapp/themes mkdir /var/www/learn/yii/firstapp/themes/classic mkdir /var/www/learn/yii/firstapp/themes/classic/views mkdir /var/www/learn/yii/firstapp/themes/classic/views/site generate themes/classic/views/.htaccess mkdir /var/www/learn/yii/firstapp/themes/classic/views/layouts mkdir /var/www/learn/yii/firstapp/themes/classic/views/system mkdir /var/www/learn/yii/firstapp/images mkdir /var/www/learn/yii/firstapp/assets mkdir /var/www/learn/yii/firstapp/css generate css/bg.gif generate css/form.css generate css/print.css generate css/ie.css generate css/main.css generate css/screen.css mkdir /var/www/learn/yii/firstapp/protected generate protected/yiic mkdir /var/www/learn/yii/firstapp/protected/views mkdir /var/www/learn/yii/firstapp/protected/views/site mkdir /var/www/learn/yii/firstapp/protected/views/site/pages generate protected/views/site/pages/about.php generate protected/views/site/contact.php generate protected/views/site/login.php generate protected/views/site/error.php generate protected/views/site/index.php mkdir /var/www/learn/yii/firstapp/protected/views/layouts generate protected/views/layouts/column2.php generate protected/views/layouts/main.php generate protected/views/layouts/column1.php mkdir /var/www/learn/yii/firstapp/protected/models generate protected/models/ContactForm.php generate protected/models/LoginForm.php mkdir /var/www/learn/yii/firstapp/protected/commands mkdir /var/www/learn/yii/firstapp/protected/commands/shell mkdir /var/www/learn/yii/firstapp/protected/components generate protected/components/UserIdentity.php generate protected/components/Controller.php mkdir /var/www/learn/yii/firstapp/protected/messages generate protected/yiic.php generate protected/.htaccess mkdir /var/www/learn/yii/firstapp/protected/extensions mkdir /var/www/learn/yii/firstapp/protected/runtime mkdir /var/www/learn/yii/firstapp/protected/tests mkdir /var/www/learn/yii/firstapp/protected/tests/unit generate protected/tests/WebTestCase.php mkdir /var/www/learn/yii/firstapp/protected/tests/report generate protected/tests/bootstrap.php mkdir /var/www/learn/yii/firstapp/protected/tests/functional generate protected/tests/functional/SiteTest.php generate protected/tests/phpunit.xml mkdir /var/www/learn/yii/firstapp/protected/tests/fixtures generate protected/yiic.bat mkdir /var/www/learn/yii/firstapp/protected/data generate protected/data/schema.mysql.sql generate protected/data/schema.sqlite.sql generate protected/data/testdrive.db mkdir /var/www/learn/yii/firstapp/protected/migrations mkdir /var/www/learn/yii/firstapp/protected/config generate protected/config/test.php generate protected/config/console.php generate protected/config/main.php mkdir /var/www/learn/yii/firstapp/protected/vendor mkdir /var/www/learn/yii/firstapp/protected/controllers generate protected/controllers/SiteController.php generate index.php |
Your application has been created successfully under /var/www/learn/yii/firstapp.
Open this application on browser.
Now your installation is complete and your first application is ready. Go to firstapp directory you will find following files and folders.
1 2 3 4 5 6 7 |
index-test.php* themes/ images/ css/ protected/ index.php assets/ |
In next tutorial, i’ll explain directory structure and show you how to configure database, create controller and model in Yii framework.