Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is Yii::app() in php framework yii

Tags:

php

yii

I am new to yii. I want to know about Yii::app(). I searched for it, but I am not able to understand it exactly.

like image 504
user3497832 Avatar asked Apr 14 '14 12:04

user3497832


People also ask

What is Yii :: app?

Applications are objects that govern the overall structure and lifecycle of Yii application systems. Each Yii application system contains a single application object which is created in the entry script and is globally accessible through the expression \Yii::$app .

What is Yii PHP framework?

The Yii[ji:] framework is an open-source PHP framework for rapidly-developing, modern Web applications. It is built around the Model-View-Controller composite pattern. Yii provides secure and professional features to create robust projects rapidly.

Where is Yii used?

It is primarily popular amongst developers for general purpose web programming. Yii has garnered popularity because of the presence of advanced caching meaning. It means that, Yii is useful for web applications with high traffic flow, such as eCommerce sites and forums.

What is Yii Best for?

Yii is the first choice of the developers over the other PHP frameworks because of its developer-friendly features. Its features are secure, reliable, and easy to configure. It is ideal for websites and web apps that are having high traffic for example web portals, eCommerce portals, or CMS Websites.


2 Answers

Yii is the Yii singleton: http://www.yiiframework.com/doc/api/1.1/Yii

Yii::app() returns the instance of CApplication: http://www.yiiframework.com/doc/api/1.1/CApplication

Which has many handy methods and variables such as user (referenced by Yii::app()->user which was information about the user)

like image 93
Jason Axelson Avatar answered Oct 09 '22 02:10

Jason Axelson


The application object encapsulates the execution context within which a request is processed. Its main task is to collect some basic information about the request, and dispatch it to an appropriate controller for further processing. It also serves as the central place for keeping application-level configuration settings. For this reason, the application object is also called the front-controller.

The application object is instantiated as a singleton by the entry script. The application singleton can be accessed at any place via Yii::app().

like image 1
MKR Avatar answered Oct 09 '22 03:10

MKR