Extension. Getting the Most out of APC for Yii. Preface ¶ The Advanced PHP Cache is a PHP extension which primarily serves as an opcode cache for PHP.
The basic idea is to save PHP from re-evaluating the PHP code to intermediate bytecode on each request. Installing and enabling APC already yields a significant performance benefit. However, APC is not a black box that will magically change all for the better. Configuring PhpStorm IDE for Yii. Configuring controller access rules to default-deny. Starting with the blog tutorial, Yii developers are familiar with the notion of access rules defined in the controller, where the actions are allowed or denied depending on the user's name or role. class CommentController extends CController { public function filters() { return array( 'accessControl' ); } public function accessRules() { return array( array('allow', 'users'=>array('@'), ), array('deny'), ); } ...
Access rules — when enabled with the accessControl token in filters() — are processed in order, from top to bottom, stopping at the first match. Show captcha after <N> unsuccessfull attempts. In this mini howto I would like to show how to add a required captcha field in the login form, after a defined number of unsuccessfull attempts.
Php - redirect Access rules with Yii. Make the Web Faster. Using Sessions with the Yii Framework. I haven’t written much about the Yii framework lately, mostly because I’ve been working night and day on the fourth edition of my “PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide” book, due out late summer 2011.
So I figured I’d put together another little blurb on the Yii framework (by regularly putting out posts on Yii, it’ll be that much easier when I go to write a book on Yii later this summer). In this post, I’m going to talk about using sessions Yii-based sites (in a separate post, I’ll discuss cookies). While not at all hard, the topic, like quite a few things, is not obvious in Yii, or well documented. The first thing to know about using sessions in Yii is that you don’t have to do anything to enable them, which is to say you don’t have to invoke session_start(), as you would in a standard PHP script. This is the behavior with Yii’s autoStart session property set to true, which is the default.
And that’s all there is to it. So…what else? Cdbhttpsession yii. Anyone here deploys Yii webapp with Capistrano? CApplication. Look up a class, method, property or event CApplication is the base class for all application classes.
An application serves as the global context that the user request is being processed. It manages a set of application components that provide specific functionalities to the whole application. The core application components provided by CApplication are the following: errorHandler: handles PHP errors and uncaught exceptions.
CApplication will undergo the following lifecycles when processing a user request: load application configuration;set up class autoloader and error handling;load static application components;onBeginRequest: preprocess the user request;processRequest: process the user request;onEndRequest: postprocess the user request; Starting from lifecycle 3, if a PHP error or an uncaught exception occurs, the application will switch to its error handling logic and jump to step 6 afterwards. Events Hide inherited events Property Details. PHP sessions lost on deployment.
Understanding "Assets" Many newcomers to Yii ask about the assets/ directory found under the webroot, and this article means to explain why it's there and how to work with it.
Background ¶ Many applications are entirely self contained, and there's no trouble or conflict putting necessary resources (images, CSS files, Javascript files, etc.) under the webroot: webroot/css/*webroot/js/*webroot/images/* and so on. If a module needs to add one more resources, it's added directly and referenced by the path down from webroot. But if one creates a module intended for widespread reuse elsewhere, naming conflicts start to emerge: How do you insure that your filename css/foo.css won't conflict with some unrelated application's attempt to use a file of the same name?
Asset Manager ¶ 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. Organize directories for applications with front-end and back-end. Large applications are often divided into front-end and back-end (or even more ends) depending on the target user groups.
The front-end should be used by common users, while the back-end mainly the administrators or staff members. The two ends usually have dramatically different appearance, even though they may share a lot of code underneath. In this tutorial, we describe a way of organizing directories of the code for both ends. Note: The directory organization described in this tutorial is meant to serve as a referential implementation.
It is not a standard. To start with, we give out the directory organization as follows, Organize directories for applications with front-end and back-end. Large applications are often divided into front-end and back-end (or even more ends) depending on the target user groups.
The front-end should be used by common users, while the back-end mainly the administrators or staff members. The two ends usually have dramatically different appearance, even though they may share a lot of code underneath. In this tutorial, we describe a way of organizing directories of the code for both ends. Note: The directory organization described in this tutorial is meant to serve as a referential implementation. It is not a standard. To start with, we give out the directory organization as follows, 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. First, create a new web application with yiic tool. I used an application generated by Yii 1.1.1, but everything described below should work with other versions of Yii Framework (probably with minor changes). Now let's modify some directories' structure to separate front-end and back-end related files. Since application's ends usually use the same models, but different controllers and views, we will separate them by creating two subdirectories under protected/controllers and protected/views directories: