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.

MVC-Yii Framework

Web programming widely adopt a special type of deign pattern i.e. MVC(Model-View-Controller) that implements in Yii. Aims of MVC is to separate business logic from user consideration so that developer can change each part without affecting the other. In which model represents the data or the defined business rules View contains the elements of the user interface such as text form inputs and controller manage between the both model and view.

RESTful APIs in PHP

REST stands for representational state transfer. It distributing the data to different kind of applications. It is the software architectural style of the WWW. REST coordinates with the set of constraints that applied to the design of components in the distributed hypermedia system that lead to high performance and more maintainable architecture. REST take the advantage of HTTP request methods to layer itself into existing HTTP architecture and consist some operations like GET, PUT, POST, DELETE.

Multi-Tier Caching Support

{" "} Caching in the yii framework is the effective way to improve the performance of a web application. To save the time what we can do is to store the static data in cache and serving it cache when requested. Cache in yii mainly involves accessing the application components that uses memcache with two cache servers.

ActiveRecords in Yii framework

{" "} It is difficult to maintain a type of code that are mixed with the SQL statement so to overcome from this problem we use ActiveRecord(AR). It is an object-Relational-Mapping(ORM) technique in which each AR className represents database table whose attributes represents as AR className properties and row represents as AR instance. So that we can access our data in a more object-oriented way.

Starting development in Yii Framework

  • Preparation

  • 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.

    Yii Database
  • Create Database

  • 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+.

To get help in your Yii Framework Project Contact Us

{" "} Read about PHP and PHP Framework Here