Yii

Facebook Twitter

Using Yii with PHP 5.4 built-in webserver instead of Apache. Since version 5.4 PHP can work as a simple webserver so you can develop Yii applications without installing Apache.

Using Yii with PHP 5.4 built-in webserver instead of Apache

That's how to use it: Open command line and cd to webroot (where your index.php is).Run PHP as webserver: path/to/php -S localhost:8080. Yii PHP Framework 1.1.8 is released | News | Yii Framework. We are very pleased to announce the immediate availability of Yii Framework version 1.1.8.

Yii PHP Framework 1.1.8 is released | News | Yii Framework

In this release, we included more than 80 new features, enhancements and bug fixes. For the complete list of changes in this release, please see the change log and important feature additions. And if you plan to upgrade from an older version to 1.1.8, refer to the upgrade instructions. In the following, we briefly introduce some of the most exciting new features in this release. Thank you for your support! How to know and change Paths. Behaviors & events. These features provide endless possibilities and unbelievable flexibility, but as current documentation does not give more than a few examples, it might be difficult to fully understand their internals and requirements.

Behaviors & events

It should be noted that they do mostly the same thing. You can attach behaviors and event handlers to components to modify the components' behavior. Events ¶ It is useful when you want to interrupt the normal application flow without extending base classes. CClipWidget. Dynamic Sidebar using CClipWidget. The Problem ¶ Most applications will have one or two sidebars and often you want to control the content that should appear in the sidebar based on the action.

Dynamic Sidebar using CClipWidget

For example you will want to show something different on the homepage as opposed to some view page. While achieving this you generally also want to avoid putting the layout into each view, as that would mean if you wanted to change the layout (e.g. put the sidebar on the left instead of the right or do some funky layout which requires an additional div tag to be added) you'd have to go through every view, which does not achieve good code re-use. It is also bad practice to have lots of if statements in column2 layout just so that you can generate the sidebar correctly. The Solution ¶ Portlets: Creating User Menu Portlet | Building a Blog System Using Yii | Yii Framework. Based on the requirements analysis, we need three different portlets: the "user menu" portlet, the "tag cloud" portlet and the "recent comments" portlet.

Portlets: Creating User Menu Portlet | Building a Blog System Using Yii | Yii Framework

We will develop these portlets by extending the CPortlet widget provided by Yii. In this section, we will develop our first concrete portlet - the user menu portlet which displays a list of menu items that are only available to authenticated users. The menu contains four items: Approve Comments: a hyperlink that leads to a list of comments pending approval;Create New Post: a hyperlink that leads to the post creation page;Manage Posts: a hyperlink that leads to the post management page;Logout: a link button that would log out the current user.

URL component access functions. Many applications wish to obtain parts of the URL for the current page (the hostname, the query string, etc.), and the CHttpRequest class wraps various $_SERVER variables to break down the URL into its constituent parts.

URL component access functions

It's sometimes confusing to read the descriptions of each one and know exactly what it represents, so this page shows a full URL with all the parts broken out. FULL URL -----> PROPERTY hostInfo port 8080 baseUrl /project url /project/index.php? Setting and maintaining the language in Application (i18n) As seen in this post, Yii doesn't enforce how language is set and maintained within the session.

Setting and maintaining the language in Application (i18n)

According to that post, the preferred method is to create a base controller which implements code for maintaining the language state. That Controller is then used in your code instead of CControler (by defing your classes with "class ... extends MyController") Here's my method of implementing this idea: How to use an application behavior to maintain runtime configuration. In this tutorial will be explained a method to manage some configuration runtime.

How to use an application behavior to maintain runtime configuration

This excellent tutorial follows a similar approach, but requires to write a masterclass which all controllers are supposed to extend, following this wiki you can achieve the same by only editing the configuration. This is often needed to manage internationalization, themes and other configuration that depends from the user. The most comfortable way is to user an application behavior. In this example we save the language in the session, but it can also be saved in the database. Create a file in components named ApplicationConfigBehavior and copy this code: What I learned from Yii Blog Tutorial so far. I have developed some apps based on Yii but I still found that I haven't used all the strong feature from Yii.

What I learned from Yii Blog Tutorial so far

I re-worked with Yii Blog Tutorial and just want to make a quick summary with Yii features. What I learned from the Yii Blog Tutorial so far 1/ We can scaffold the Model, Controller , not only to main controller , model folders but also to Modules folder 2/

Yii-cms

Text Ascii Art Generator. UrlManager Rules: delete "site" from the url. UrlManager rules for route aliases. Y!!

urlManager rules for route aliases

, on 13 April 2010 - 01:26 PM, said: Are you not using path format in urlmanager config? You can do: 'rules' => array( 'this/is/an-example' => 'module/controller/action',), The directory structure of the Yii project site. In this article, we describe the directory structure used by yiiframework.com - the official Yii framework website. While this structure may look overly complicated for small projects or may not be optimal in some sense, we believe it is appropriate for medium or large projects in a team development environment. In fact, we have successfully used the similar structure in some other big projects.

Overall Structure ¶ Below is the directory structure we are using: / backend/ common/ components/ config/ params.php params-local.php * lib/ Pear/ yii/ Zend/ migrations/ models/ Comment.php Extension.php ... console/ commands/ SitemapCommand.php ... config/ main.php main-local.php * params.php params-local.php * runtime/ yiic.php * frontend/ components/ config/ main.php main-local.php * params.php params-local.php * controllers/ SiteController.php ... lib/ models/ ContactForm.php SearchForm.php runtime/ views/ layouts/ site/ www/ assets/ css/ js/ index.php * yiic yiic.bat. Special Topics: URL Management | The Definitive Guide to Yii | Yii Framework. Complete URL management for a Web application involves two aspects: When a user request comes in terms of a URL, the application needs to parse it into understandable parameters.The application needs to provide a way of creating URLs so that the created URLs can be understood by the application.

For a Yii application, these are accomplished with the help of CUrlManager. Note: You can specify URLs without using Yii but it is not recommended since you will not be able to easily change URLs via configuration without touching application code or to achieve application portability. 1. Creating URLs ¶ Issue 41 - yii-rights - Implement support for method 'actions' of controllers - Access control module for Yii PHP framework. Organize directories for applications with front-end and back-end using WebApplicationEnd behavior. Previously there was described a way to build an application with front-end and back-end.

I would like to continue this theme and suggest another way to organize directories using WebApplicationEnd behavior. If you are not familiar with events & behaviors yet, then please, read this tutorial to get basic knowledge about using them. Yii Framework. Yii DAO vs Active Record Performance | SHELDMANDU. Home » PHP » PHP MVC Frameworks » Yii DAO vs Active Record Performance I’m writing a new app using Yii Framework, but one of my concerns with Yii has been the impact of using ActiveRecord and ORM on the application performance, so I decided to actually compare how the two perform and the results are quite interesting… Basically for a simple test what I did is created a single table in the database with like 6 records. CDbCriteria. Look up a class, method, property or event CDbCriteria represents a query criteria, such as conditions, ordering by, limit/offset.

It can be used in AR query methods such as CActiveRecord::find and CActiveRecord::findAll. $criteria=new CDbCriteria(); $criteria->compare('status',Post::STATUS_ACTIVE); $criteria->addInCondition('id',array(1,2,3,4,5,6)); $posts = Post::model()->findAll($criteria); Select distinct value.