smarty\ViewRenderer $extensionClass

$extensionClass public property Extension class name public string $extensionClass = '\yii\smarty\Extension'

smarty\ViewRenderer $compilePath

$compilePath public property The directory or path alias pointing to where Smarty compiled templates will be stored. public string $compilePath = '@runtime/Smarty/compile'

smarty\ViewRenderer $cachePath

$cachePath public property The directory or path alias pointing to where Smarty cache will be stored. public string $cachePath = '@runtime/Smarty/cache'

Shared Hosting Environment

Deploying a basic project template Deploying an advanced project template Shared hosting environments are often quite limited about configuration and directory structure. Still in most cases you can run Yii 2.0 on a shared hosting environment with a few adjustments. Deploying a basic project template Since in a shared hosting environment there's typically only one webroot, use the basic project template if you can. Refer to the Installing Yii chapter and install the basic project template lo

Sessions and Cookies

Sessions Cookies Sessions and cookies allow data to be persisted across multiple user requests. In plain PHP you may access them through the global variables $_SESSION and $_COOKIE, respectively. Yii encapsulates sessions and cookies as objects and thus allows you to access them in an object-oriented fashion with additional useful enhancements. Sessions Like requests and responses, you can get access to sessions via the session application component which is an instance of yii\web\Session, b

Service Locator

A service locator is an object that knows how to provide all sorts of services (or components) that an application might need. Within a service locator, each component exists as only a single instance, uniquely identified by an ID. You use the ID to retrieve a component from the service locator. In Yii, a service locator is simply an instance of yii\di\ServiceLocator or a child class. The most commonly used service locator in Yii is the application object, which can be accessed through \Yii::$a

Routing and URL Creation

URL Formats Routing Creating URLs Using Pretty URLs Performance Consideration When a Yii application starts processing a requested URL, the first step it takes is to parse the URL into a route. The route is then used to instantiate the corresponding controller action to handle the request. This whole process is called routing. The reverse process of routing is called URL creation, which creates a URL from a given route and the associated query parameters. When the created URL is later requeste

Routing

With resource and controller classes ready, you can access the resources using the URL like http://localhost/index.php?r=user/create, similar to what you can do with normal Web applications. In practice, you usually want to enable pretty URLs and take advantage of HTTP verbs. For example, a request POST /users would mean accessing the user/create action. This can be done easily by configuring the urlManager application component in the application configuration like the following: 'urlManager'

rest\ViewAction run()

run() public method Displays a model. public yii\db\ActiveRecordInterface run ( $id )$id string The primary key of the model. return yii\db\ActiveRecordInterface The model being displayed

rest\UrlRule parseRequest()

parseRequest() public method Parses the given request and returns the corresponding route and parameters. public array|boolean parseRequest ( $manager, $request )$manager yii\web\UrlManager The URL manager $request yii\web\Request The request component return array|boolean The parsing result. The route and the parameters are returned as an array. If false, it means this rule cannot be used to parse this path info.