Chapter 1. Starting with Yii2

Yii2 is a complete rewrite of the first version of one of the most famous PHP frameworks. It is a well-documented framework with a very active community.

Officially, we can find three types of support: a guide, for a complete navigation through framework topics at http://www.yiiframework.com/doc-2.0/guide-index.html, a reference to explore all classes that compose the framework at http://www.yiiframework.com/doc-2.0/index.html, and finally forum support at http://www.yiiframework.com/forum/.

In this chapter, we will go through the following:

  • Requirements and tools
  • Installing Yii2 with Composer
  • Application structure
  • Application properties
    • Common application components
    • Handling application events
    • Pattern MVC in Yii2
  • Naming convention
    • Configuring debug toolbar
    • Using logger
    • Example – hello world from scratch with the Yii basic template and bootstrap template

Requirements and tools

The basic requirements for Yii2 are a web server (local or remote) and PHP v.5.4 (or newer). It is recommended to have a shell (or command line) access to the machine (local or remote) where we store the code, as there are scripts that it will be very beneficial to use in the development of complex applications. We can also develop the application locally and upload it to the web server when we wish to test it.

For remote hosting, there are multiple options. We can use a simple web hosting service (with PHP v.5.4 support) or we can opt for virtual or dedicated server hosting. Keep in mind that with the former option, if the server doesn't meet the PHP requirements, it can be difficult to change whatever is wrong.

Yii2 has a script, requirements.php, which checks whether our hosting meets the requirements to run Yii2 application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.78.174