Yii – Layouts
Layouts represent the common parts of multiple views i.e. for example, page header and footer. By default, layouts should be stored in the views/layouts folder. Let us have a look at the…
Layouts represent the common parts of multiple views i.e. for example, page header and footer. By default, layouts should be stored in the views/layouts folder. Let us have a look at the…
Views are responsible for presenting the data to end users. In web applications, Views are just PHP script files containing HTML and PHP code. Creating Views Step 1 − Let us have a…
A module is an entity that has its own models, views, controllers, and possibly other modules. It is practically an application inside the application. Step 1 − Create a folder called modules inside…
A widget is a reusable client-side code, which contains HTML, CSS, and JS. This code includes minimal logic and is wrapped in a yii\base\Widget object. We can easily insert and apply this…
Models are objects representing business logic and rules. To create a model, you should extend the yii\base\Model class or its subclasses. Attributes Attributes represent the business data. They can be accessed like…
To create an action in a controller class, you should define a public method whose name starts with the word action. The return data of an action represents the response…
Controllers in web applications should extend from yii\web\Controller or its child classes. In console applications, they should extend from yii\console\Controller or its child classes. Let us create an example controller in the controllers folder.…
Controllers are responsible for processing requests and generating responses. After user's request, the controller will analyze request data, pass them to model, then insert the model result into a view,…
Entry scripts are responsible for starting a request handling cycle. They are just PHP scripts accessible by users. The following illustration shows the structure of an application − Web application…
There is only one folder in the overall code base that is publicly available for the web server. It is the web directory. Other folders outside the web root directory…