ebook img

Agile Web Application Development with Yii1.1 and PHP5 PDF

368 Pages·2010·3.644 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Agile Web Application Development with Yii1.1 and PHP5

Agile Web Application Development with Yii 1.1 and PHP5 Fast-track your web application development by harnessing the power of the Yii PHP Framework Jeffery Winesett BIRMINGHAM - MUMBAI Agile Web Application Development with Yii 1.1 and PHP5 Copyright © 2010 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: August 2010 Production Reference: 1030810 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-847199-58-4 www.packtpub.com Cover Image by Vinayak Chittar ([email protected]) Credits Author Editorial Team Leader Jeffery Winesett Aanchal Kumar Reviewers Project Team Leader Imre Mehesz Priya Mukherji Jonah Turnquist Kyle Ferreira Project Coordinator Prasad Rai Acquisition Editor Usha Iyer Proofreader Lesley Harrison Development Editors Dhwani Devater Graphics Geetanjali Sawant Reshma Sundaresan Production Coordinator Technical Editors Melwyn D'sa Aditya Belpathak Hyacintha D'Souza Cover Work Melwyn D'sa Indexer Hemangini Bari About the Author Jeffery Winesett is the director of software engineering and application development at Control Group Inc., a New York based consulting firm specializing in delivering technology for big ideas. He has spent the last five of his twelve years of software development focused on delivering large-scale PHP-based applications. Jeffery also writes articles on the topics of PHP, web application frameworks, and software development. He has enjoyed being a Yii evangelist since its early alpha version. I'd like to thank all of the technical reviewers, editors, and staff at Packt for their fantastic contributions, suggestions, and improvements. I'd like to thank Qiang Xue and the entire Yii Framework developer team for creating and maintaining this brilliant framework. Ryan Trammel at Scissortail design for his attention to detail and CSS assistance. My lovely wife Tiffany, for her endless patience throughout this project and Lemmy and Lucie for providing me with an endless supply of sunshine. About the Reviewers Imre Mehesz is a long-time open source and PHP enthusiast. He started with the classic LAMP stack around 2000 and grew into the MVC world with CakePHP, ZendFramework, and now Yii. He brought Yii into his professional life and runs the Yii Radio podcast. I would like to thank Qiang for creating this framework, and my wife who puts up with my craziness for open source development. Jonah Turnquist is a self-taught web developer and a college student. He is a part of the developer team for the Yii Framework, mainly contributing to the official extension library, Zii. Meanwhile, he is attending a junior college in California, and he is on his way to being transferred to a four year degree in college in the Fall of 2010. He is studying Electrical Engineering and Computer Sciences. Kyle Ferreira is a student at the University of Ontario, Institute of Technology taking a four year degree in IT (BIT) under Network Security. As a student, he has spent a lot of time researching IT security-related topics, and has valued experience working with various computer languages and equipment. He's currently running his own business in web design and development, using the Yii Framework as the basis for a lot of large projects. I would like to thank Packt Publishing and its staff for this opportunity to contribute to this production. I'd also like to thank Qiang Xue for his exceptional devotion to a well designed and functioning framework, and for his guidance in helping me learn and contribute to the framework. Table of Contents Preface 1 Chapter 1: Meet Yii 7 Yii is easy 8 Yii is efficient 8 Yii is extensible 9 MVC architecture 9 The model 10 The view 10 The controller 10 Stitching these together: Yii request routing 11 Blog posting example 11 Object-relational mapping and Active Record 13 Active Record 14 The view and controller 14 Summary 15 Chapter 2: Getting Started 17 Installing Yii 17 Installing a database 19 Creating a new application 19 Hello, World! 22 Creating the controller 22 One final step 26 Reviewing our request routing 27 Adding dynamic content 28 Adding the date and time 28 Adding the date and time, a better approach 29 Moving the data creation to the controller 29 Have you been paying attention? 30 Table of Contents Linking pages together 31 Linking to a new page 31 Getting a little help from Yii CHtml 32 Summary 34 Chapter 3: The TrackStar Application 35 Introducing TrackStar 35 Creating user stories 36 Users 36 Projects 36 Issues 37 Navigation and page flow 38 Defining a data scheme 39 Defining our development methodology 41 Automated software testing 41 Unit and functional testing 41 Benefits of testing 42 Test-driven development 43 Testing in Yii 43 Unit tests 44 Installing PHPUnit 45 Functional tests 45 Installing Selenium 45 Running a quick example 46 Hello TDD! 47 Summary 52 Chapter 4: Iteration 1: Creating the Initial TrackStar Application 53 Iteration planning 53 Creating the new application 54 Connecting to the database 55 Testing the connection 55 Yii and databases 57 Adding a db connection as an application component 58 Summary 60 Chapter 5: Iteration 2: Project CRUD 61 Iteration planning 61 Running our test suite 62 Creating the project table 62 Naming conventions 63 Creating the AR model class 64 Configuring Gii 65 Using Gii to create our Project AR class 66 [ ii ] Table of Contents Testing out our newly generated code 68 Creating the unit test file 69 Testing create 69 Testing read 71 Testing update and delete 72 Was all that testing really necessary? 73 Enabling CRUD operations for users 73 Creating CRUD scaffolding for projects 74 Creating a new project 77 Adding a required field to our form 78 Reading the project 82 Updating and deleting projects 83 Managing projects in admin mode 83 More on testing—fixtures 85 Configuring the fixture manager 86 Creating a fixture 86 Configuring this fixture for use 88 m> o Specifying a test database 89 ok.c o Using fixtures 90 eb w Summary 92 wo w. w Chapter 6: Iteration 3: Adding Tasks 93 w < Iteration planning 93 ook B e Running the test suite 94 w! o W Designing the schema 95 m o Defining some relationships 95 d fr a Building the database and the relationships 96 nlo w o Creating the Active Record model classes 98 D Creating the Issue model class 98 Creating the User model class 101 Creating the Issue CRUD operations 101 Using the Issue CRUD operations 102 Creating a new Issue 103 Adding the types drop-down menu 104 Getting the test in the "Red" 105 Moving From "Red" To "Green" 105 Moving Back To "Red" 106 Getting back to "Green" once again 107 Adding the issue type dropdown 107 Adding the status drop-down menu: Do it yourself 111 Fixing the owner and requester fields 112 Enforcing a project context 112 Implementing a filter 113 [ iii ]

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.