Yii Framework
About Yii Framework
It is a high performance Framework which support PHP for developing web application and APIs. It also open-source Web development Application Framework which support clean design and rapid development and also help to make efficient, extensible and maintainable end product. It is best choice for the sized project which has been built with the sophisticated and enterprise application and you have a full control over configuration from presentation to persistence. Yii framework comes into packaged tools with the clear and comprehensive documentation. It is especially suitable for developing large-scale application like e-commerce projects, portals, web services and so on.
How Yii Framework is different from others?
There are few important points that need to be remember to make it different from other frameworks: High performance is the primary goal of yii,{" "} It implements the MVC(Model view Controller) pattern that promotes code organization which based on MVC, {" "} yii is full-stack framework which provide ready to use features:{" "} RESTful API development support, multi-tier caching support, ActiveRecord for relational and SQL database, so on.
Starting development in Yii Framework
-
Preparation
-
Create Database
In this step download and install the Yii Framework on your system and simply run a console command to generate skeleton of web application that built with yii. It is a good starting point to build an application with the more sophisticated features.
The framework eliminates most repetitive coding task this often starts with designing the whole system to be built, in terms of database schema.
AR relies on a DB connection to perform DB-related operations and it assumes that the db application component gives the needed CDbConnection instance which serves as the DB connection. The following application configuration shows an example:
{` return array( 'components'= > array( 'db'= > array( 'className'= >'system.db.CDbConnection', 'connectionString'= >'sqlite:path/to/dbfile', // turn on schema caching to improve performance // 'schemaCachingDuration'= > 3600, ), ), );`}
Generates the Model Classes
In this step the main purpose is to transform the database into functional PHP code. By using built-in web based code generator, we can turn database table definition into model classes without writing a single line code. After that you easily can access the database in object-oriented fashion.
Generated CRUD code
Using above mention code generator, we can further generate code that implements the CRUD features for the selected database tables. CRUD stands for create, read, update, delete features. The generated CRUD code is highly usable and customizable which follow the MVC architecture. It can does all the work without using a single line of code.
Customize the code to for exact needs
In this phase of development process you need to customize the code which you needs. For Example: if you want to hide the password section in user administration page the you should simply cross out the admin view file
Themes in Yii framework
Theming is the static way of customizing the outlook of a web page. By applying new themes you can instantly change overall appearance of a web page or to the whole application. In yii theme is represented as a directory which consist of view files, layout files, relevant resources like images, css files, javascript files, etc. name is itself with the directory name and one theme should be active at a time only.
Yii-Bootstrap: It is an extension to Yii that provides a wide range of widgets which allow users to easily use bootstrap with yii. All the widgets follow Yii’s conventions and work seamlessly together with bootstrap and its jquery plugins.
Debugging in Yii framework
The debug toolbar of Yii framework is a configurable set of panels that display the information about current response and request and when it has been clicked and display also about the panel content. This toolbar ported to PHP famous Django Debug Toolbar. There are some panels that have been written that are: Request timer, A list of superglobals, Application settings, SQl queries including time to execute and parameter binding, Logging output via Yii built-in logging. Requirement for this debug toolbar is Javascript enabled browser having Yii with the version 1.1.4+.