What is Yii 2.0?

What is Yii 2.0?

Yii is a high performance, component-based PHP framework for rapidly developing modern Web applications. The name Yii can be considered as the acronym for Yes It Is!. Yii 2 inherits the main spirit behind Yii for being a simple, fast and highly extensible PHP framework.

Whether you are one developer building a fairly simple Web site, or a team of distributed developers building an extremely complex Web application, using Yii is like augmenting your development team with additional experienced, professional, and efficient resources. All for free!

Yes It Is(Yii 2.0)

  1. Yii is a generic Web Development framework
  2. Yii can be used for developing all kinds of Web applications based on PHP
  3. Yii is component-based architecture and sophisticated caching support
  4. Yii is especially suitable for developing large-scale applications.
    such as portals, forums, content management systems (CMS), e-commerce projects, RESTful Web services, and so on
  5. Yii implements the MVC (Model-View-Controller) design pattern
  6. Strong core developer team
  7. Forum support available in yii site

Yii2.0 Requirements

Yii 2.0 requires PHP 5.4.0 or above.

It is better to setup Wamp server in your local  system.

Wamp server is complete PHP web development stack.It is also notice that please install Visual C/C++ 2011,12,13,14, and 2015 before wamp server setup.

Yii2.0 Features

You can stay focused on the tasks specific to your business requirements, and let Yii provide an implementation strategy for all of the following:

  1. Active Record Supporting Relational
  2. MVC (Model View Controller)
  3. RBAC
  4. RESTful API
  5. Validators
  6. Security Helper
  7. Session
  8. Sessions storage in database
  9. AJAX-enabled widgets
  10. Cookie
  11. Caching
  12. CSRF Tokens for security
  13. DAO
  14. Error Handling
  15. Gii
  16. i18n support
  17. Multi-tier caching support
  18. Namespaces, Traits features available
  19. NoSQL databases support like mongoDB
  20. Pure OOP-based framework
  21. Query builders
  22. skinning and theming
  23. URL Manager

Installing Yii2.0

We can install Yii in two ways, using Composer or downloading an archive file. The former is the preferred way as it allows you to install new extensions or update Yii by running a single command.

Step 1

Install via Composer(one time only)

The installer will download composer for you and set up your PATH environment variable so you can simply call composer from any directory.

Download and run Composer-Setup.exe – it will install the latest composer version whenever it is executed.

and run following command

php composer  global require "fxp/composer-asset-plugin:^1.2.0"

or 

composer  global require "fxp/composer-asset-plugin:^1.2.0"

Now choose one of the application templates to start installing Yii 2.0. An application template is a package that contains a skeleton Web application written in Yii.

To install the basic application template, run the command below in the www folder of wamp server:

composer create-project yiisoft/yii2-app-basic yii2basic

or 

php composer create-project yiisoft/yii2-app-basic yii2basic

Above commands will take 10-15 min for installation. please wait….

To install the advanced application template, run the command below:

composer create-project yiisoft/yii2-app-advanced advancedyii2

or 

php composer create-project yiisoft/yii2-app-advanced advancedyii2

Above commands will take 10-15 min for installation. please wait….

Install from an Archive File

Download one of the following archive files, and then extract it to a Web-accessible(www folder of wamp):

  • Yii 2 with basic application template
  • Yii 2 with advanced application template

    important Installing from an Archive File

    Installing Yii from an archive file involves three steps:

    1. Download the archive file from yiiframework.com.
    2. Unpack the downloaded file to a Web-accessible folder.
    3. Modify the config/web.php file by entering a secret key for the cookieValidationKey configuration item (this is done automatically if you are installing Yii using Composer):
      // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
      'cookieValidationKey' => 'enter your secret key here',

       

      Verifying the Installation

      After installation is done, either configure your web server (see next section) or use the built-in PHP web server by running the following console command from  the project  directory:

      php yii serve
      

      Note: By default the HTTP-server will listen to port 8080. However if that port is already in use or you wish to serve multiple applications this way, you might want to specify what port to use. Just add the –port argument:

      //if you want to change the default port otherwise leave it
      php yii serve --port=<portnumber>
      php yii serve --port=8080

      You can use your browser to access the installed Yii application with the following URL:

      http://localhost:8080/

       

Yii2 Basic Applications Structure

The most important directories and files in your application are (assuming the application’s root directory is basic):

basic/                  application base path
    composer.json       used by Composer, describes package information
    config/             contains application and other configurations
        console.php     the console application configuration
        web.php         the Web application configuration
    commands/           contains console command classes
    controllers/        contains controller classes
    models/             contains model classes
    runtime/            contains files generated by Yii during runtime, such as logs and cache files
    vendor/             contains the installed Composer packages, including the Yii framework itself
    views/              contains view files
    web/                application Web root, contains Web accessible files
        assets/         contains published asset files (javascript and css) by Yii
        index.php       the entry (or bootstrap) script for the application
    yii                 the Yii console command execution script

 

Yii2 with Netbeans

NetBeans IDE lets you quickly and easily develop Java desktop, mobile, and web applications, as well as HTML5 applications with HTML, JavaScript, and CSS. The IDE also provides a great set of tools for PHP  developers. It is free and open source and has a large community of users and developers around the world.      Download Now       must have JDK download