Since version 5.4 PHP can work as a simple webserver so you can develop Yii applications without installing Apache. That's how to use it: Open command line and cd to webroot (where your index.php is). Run PHP as webserver:
We are very pleased to announce the immediate availability of Yii Framework version 1.1.8. 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!
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. 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.
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. 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 ¶
Based on the requirements analysis, we need three different portlets: the "user menu" portlet, the "tag cloud" portlet and the "recent comments" portlet. 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.
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. 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 -----> http://www.example.com:8080/project/index.php?r=post/view&id=123 PROPERTY hostInfo http://www.example.com:8080 port 8080 baseUrl /project url /project/index.php?
As seen in this post, Yii doesn't enforce how language is set and maintained within the session. 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:
In this tutorial will be explained a method to manage some configuration runtime. 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:
I have developed some apps based on Yii but I still found that I haven't used all the strong feature from Yii. 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/ http://www.yiiframew...totype.scaffold We can scaffold the Model, Controller , not only to main controller , model folders but also to Modules folder 2/ http://www.yiiframew...
Y!!, 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' , ),
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
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.
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.
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.