Getting Started tutorial Web Application Development with Yii2 (Part 1): Installation

| | Tutorial PHP | Tutorial Web Design |

Getting Started tutorial Web Application Development with Yii2 (Part 1): Installation
Yii2 was born with a number of improvements and the addition of new features. One of Yii2's other strengths is the well-structured and complete documentation so that Yii v1.x users can readjust the source code with v2.x. For beginners Yii2 has a pretty clear and complete cookbook but still in English.

In Indonesia alone, active communities discussing Yii and Yii2 can be found on Facebook. There are some very active groups discussing Yii. Here is a list of Facebook groups that discuss Yii:
  • PHP Indonesia with the number of 108,401 members only in this group not only Yii discussed.
In addition to joining the Yii Facebook group from Indonesia, you can join the Yii International group where there are some core contributors of Yii2 who can join you in discussions. You can join the Yii PHP Framework group. 


There are two ways to download Yii2 one of them through the composer or download directly by choosing the basic or advance version. You can download Yii2 directly from the following link:
Or you can install through the composer as in the following ways:

$ php composer.phar create-project yiisoft/yii2-app-basic basic 2.0.8
$ php composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.8
More details You can read the official guide at http://www.yiiframework.com/download/. Now please download Yii2 basic version then extract it using WinRAR or 7zip then please put it in htdocs if you use XAMPP or /var/www/html if you use standalone Apache2. And after putting the Yii2 folder change its name to hello-yii.

Now please access the URL http://localhost/hello-yii/web/index.php through a web browser and you will see a beautiful page as shown below: 


View the Yii2 folder structure

More details You can read a more meaningful explanation in the Yii2 documentation, before you even ask better to read Yii2 documentation first. But here is a brief explanation of the basic Yii2 folder structure:
  • Assets, contains assets and defines the assets set in the AppAsset.php file
  • Commands, contains files that will be executable through the console. You will find a file called HelloController.php when downloading the basic version.
  • Config, contains files to manage the web apps you build. Inside the folder there are four main files are console, db, params, and web
  • Controllers, contains the controller files you will write to compile the actions that will be accepted by the web app you build.
  • Mail, containing a special view file for e-mail
  • Models, contains a model file that will define the tables of the database you are using and you can use in the controller you have created to access the database. You can create two types of classes inherited from ActiveRecord or Model.
  • Runtime, contains the files that were generated when the Yii2 web application was started.
  • Tests, contains files that will run testing for web applications. You can use CodeCeption to test your Yii2 web application
  • Vendor, contains the file where the Yii2 library is located. You can also install various PHP libraries via Composer 
  • Views, contains files for writing views and templates to use in displaying web pages.
  • Web, contains index.php files and static assets for Yii2 web pages

Yii Console commands

Other Yii2 features that are not less cool than Yii2 Debugger is Yii2 Console. Where you can do some things you can run through the console. When you enter the Yii2 folder via the console, you can run a script named yii in the console as follows:

Yii Console commands
Yii2 Console accommodates you to perform tasks such as:
  • Database migration
  • Running the default web server Yii2
  • Run the command you create through the controller you place in the commands folder
  • Manage assets and cache
  • Using dummy data with Fixture
  • Generate controller code, model, or auto CRUD using Gii 


Yii2 can be your choice to create more reliable and structured web applications. Yii2 comes with improved documentation and features. Of course the official documentation is better and better answer the problems you find. You can also start exploring The Definitive Guide to Yii2 to try Yii2 more deeply. You can visit the official user guide at http://www.yiiframework.com/doc-2.0/guide-index.html

Disclaimer: Images, Content of articles or videos that exist on the web sometimes come from various sources of other media. Copyright is fully owned by the source. If there is a problem with this matter, you can contact us here.
How to style text in Disqus comments:
  • To write a bold letter please use <strong></strong> or <b></b>.
  • To write a italic letter please use <em></em> or <i></i>.
  • To write a underline letter please use <u></u>.
  • To write a strikethrought letter please use <strike></strike>.
  • To write HTML code, please use <code></code> or <pre></pre> or <pre><code></code></pre>, and please parse the code in the parser box below.
Show Parser Box