Yii 1.1 Application Development Cookbook

There is a newer version of this book available - Yii Application Development Cookbook - Second Edition
Yii 1.1 Application Development Cookbook
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • Learn to use Yii more efficiently through plentiful Yii recipes on diverse topics
  • Make the most efficient use of your controller and views and reuse them
  • Automate error tracking and understand the Yii log and stack trace
  • Full of practically useful solutions and concepts that you can use in your application, with clearly explained code and all the necessary screenshots

Book Details

Language : English
Paperback : 392 pages [ 235mm x 191mm ]
Release Date : August 2011
ISBN : 1849515484
ISBN 13 : 9781849515481
Author(s) : Alexander Makarov
Topics and Technologies : All Books, Web Development, Cookbooks, Open Source, PHP, Web Development

Table of Contents

Chapter 1: Under the Hood
Chapter 2: Router, Controller, and Views
Chapter 3: AJAX and jQuery
Chapter 4: Working with Forms
Chapter 5: Testing your Application
Chapter 6: Database, Active Record, and Model Tricks
Chapter 7: Using Zii Components
Chapter 8: Extending Yii
Chapter 9: Error handling, Debugging, and Logging
Chapter 10: Security
Chapter 11: Performance Tuning
Chapter 12: Using External Code
Chapter 13: Deployment
  • Chapter 1: Under the Hood
    • Introduction
    • Using getters and setters
    • Using Yii events
    • Using import and autoloading
    • Using exceptions
    • Configuring components
    • Configuring widget defaults
    • Using Yii core collections
    • Working with request
    • Chapter 2: Router, Controller, and Views
      • Introduction
      • Configuring URL rules
      • Generating URLs by path
      • Using regular expressions in URL rules
      • Creating URL rules for static pages
      • Providing your own URL rules at runtime
      • Using base controller
      • Using external actions
      • Displaying static pages with CViewAction
      • Using flash messages
      • Using controller context in a view
      • Reusing views with partials
      • Using clips
      • Using decorators
      • Defining multiple layouts
      • Paginating and sorting data
      • Chapter 3: AJAX and jQuery
        • Introduction
        • Loading a block through AJAX
        • Managing assets
        • Including resources into the page
        • Working with JSON
        • Passing configuration from PHP to JavaScript
        • Handling variable number of inputs
        • Chapter 4: Working with Forms
          • Introduction
          • Writing your own validators
          • Uploading files
          • Adding CAPTCHA
          • Customizing CAPTCHA
          • Creating a custom input widget with CInputWidget
          • Chapter 5: Testing your Application
            • Introduction
            • Setting up the testing environment
            • Writing and running unit tests
            • Using fixtures
            • Testing the application with functional tests
            • Generating code coverage reports
            • Chapter 6: Database, Active Record, and Model Tricks
              • Introduction
              • Getting data from a database
              • Defining and using multiple DB connections
              • Using scopes to get models for different languages
              • Processing model fields with AR event-like methods
              • Applying markdown and HTML
              • Highlighting code with Yii
              • Automating timestamps
              • Setting an author automatically
              • Implementing single table inheritance
              • Using CDbCriteria
                • Chapter 8: Extending Yii
                  • Introduction
                  • Creating model behaviors
                  • Creating components
                  • Creating reusable controller actions
                  • Creating reusable controllers
                  • Creating a widget
                  • Creating CLI commands
                  • Creating filters
                  • Creating modules
                  • Creating a custom view renderer
                  • Making extensions distribution-ready
                    • Chapter 10: Security
                      • Introduction
                      • Using controller filters
                      • Using CHtml and CHtmlPurifier to prevent XSS
                      • Preventing SQL injections
                      • Preventing CSRF
                      • Using RBAC
                      • Chapter 11: Performance Tuning
                        • Introduction
                        • Following best practices
                        • Speeding up sessions handling
                        • Using cache dependencies and chains
                        • Profiling an application with Yii
                          • Chapter 13: Deployment
                            • Introduction
                            • Changing the Yii directories layout
                            • Moving an application out of webroot
                            • Sharing the framework directory
                            • Moving configuration parts into separate files
                            • Using multiple configurations to simplify the deployment
                            • Implementing and executing cron jobs
                            • Maintenance mode

                            Alexander Makarov

                            Alexander Makarav is an experienced engineer from Russia and has been a Yii framework core team member since 2010. Before joining the Yii core team, he participated in the CodeIgniter community growth in Russia. In 2009, he finished the Russian translation of the framework documentation and created the Russian community website. In 2012, he released the Russian version of the book along with Russian community members. In the same year, he was the technical reviewer for three more books:

                            • The Yii Book: Developing Web Applications Using the Yii PHP Framework, Larry Ullman
                            • Web Application Development with Yii and PHP, Jeff Winesett
                            • Yii Rapid Application Development Hotshot, Lauren O'Meara and James Hamilton

                            In his free time, Alexander writes technical blog at http://rmcreative.ru/, speaks at conferences, and enjoys movies, music, traveling, photography, and languages. He currently resides in Voronezh, Russia with his beloved wife and daughter.

                            Sorry, we don't have any reviews for this title yet.

                            Code Downloads

                            Download the code and support files for this book.

                            Submit Errata

                            Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                            - 1 submitted: last submission 26 Apr 2013

                            Errata type: Typo | Page number: 96

                            In the diagram the last line of text states: '0 or Nore'. This must be '0 or More'


                            Sample chapters

                            You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                            Frequently bought together

                            Yii 1.1 Application Development Cookbook +    Microsoft System Center 2012 Configuration Manager: Administration Cookbook =
                            50% Off
                            the second eBook
                            Price for both: $39.00

                            Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                            What you will learn from this book

                            • Make internal Yii features, such as events and collections, useful
                            • Get the maximum out of your Controller and Views and make them reusable
                            • Work with jQuery, JavaScript, and AJAX the Yii way
                            • Use "hidden" core Yii input widgets and write your own widgets
                            • Make your application error-free using the TDD approach
                            • Use Active Record efficiently
                            • Utilize Zii components such as grids and data providers
                            • Implement, package, and share your code as a reusable extension
                            • Automate error tracking and understand the Yii log and stack trace
                            • Keep your implementation secure, filter input, and escape output
                            • Tune your application for best performance and learn general performance principles and Yii-related settings
                            • Include non-Yii code, such as Zend Framework or PEAR, in your application
                            • Simplify team development and manage Yii configuration in a very efficient way

                            In Detail

                            When Alex told me he was about to write a Yii cookbook about a year ago, I was wondering how original it would be, considering the fact that there was already an online user-contributed cookbook (aka. Yii wiki). It turned out Alex produced a book that is not only full of wisdom about how to use Yii effectively, but also presented in such a systematic way that it can be taken as an essential companion book to the definitive guide to Yii. In fact, Alex has successfully intrigued the interest of every member in the Yii developer team when he asked for review and comments on his newly finished book chapters.

                            As the founder and the lead developer of the Yii framework, I feel this book is a must-read for every Yii programmer. While this book does not describe directly the rules set by Yii, it shows how to program with Yii from a practical perspective. People who are driven by tight project schedules will find this book very handy as it gives ready-to-use solutions to many problems they may face in their projects; people who are already familiar with Yii will also find this book very informative as most problem solutions given in the book can be considered as officially recommended because they have undergone thorough review of every Yii developer team member. Alex, through this book and his active participation in the Yii project, proved himself to be a great programmer as well as a good writer.

                            Qiang Xue
                            Lead developer of the Yii framework

                            Yii framework is a rapidly growing PHP5 MVC framework often referred to as Rails for PHP. It has become a solid base for many exciting web applications such as Stay.com and Russia Today's meetfriends.rt.com and can be a good base for your developments. Yii is an object-oriented, high-performance, component-based PHP web application framework. Yii is pronounced as Yee and is an acronym for "Yes It Is!".

                            Familiar with Yii and want to exploit it to its full potential, but do not know how to go about it? Yii 1.1 Application Development Cookbook will show you how to use Yii efficiently. You will learn about implementing shortcuts using core features, creating your own reusable code base, using test-driven development, and many more topics that will escalate your knowledge in no time at all!

                            Yii 1.1 Application Development Cookbook will help you learn more about Yii framework and application development practices in general with demonstrations of shortcuts and information about dangerous things you should not do.

                            Grouped in 13 chapters, the recipes will assist you to write your applications exploiting Yii core functionality to its full potential. The chapters are generally independent of each other and you can start reading from the chapter you need most, whether it is "AJAX and jQuery", "Database, Active Record and Model Tricks" or "Extending Yii". The most interesting topics include Yii application deployment, a guide to writing your own extensions, advanced error handling, debugging and logging, application security, and performance tuning.

                            Yii 1.1 Application Development Cookbook will help you utilize Yii functionalities completely and efficiently.

                            A practical cookbook on the Yii MVC framework covering the most important internal features of Yii and useful tips on Yii application development


                            This book is a collection of Yii recipes with chapters generally independent of each other. It is full of practically useful solutions and concepts explained with code and the required pictorial illustrations.

                            Who this book is for

                            If you are a developer with a good knowledge of PHP5, are familiar with the basics of Yii, and have tried to develop applications using Yii, then this book is for you. Knowledge of the object oriented approach and MVC pattern will be a great advantage as Yii uses these extensively.

                            Code Download and Errata
                            Packt Anytime, Anywhere
                            Register Books
                            Print Upgrades
                            eBook Downloads
                            Video Support
                            Contact Us
                            Awards Voting Nominations Previous Winners
                            Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                            Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software