1. Trang chủ
  2. » Công Nghệ Thông Tin

Agile Web Application Development with Yii 1.1 and PHP5

368 575 20
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 368
Dung lượng 6,61 MB

Nội dung

Fast-track your web application development by harnessing the power of the Yii PHP Framework

Agile Web Application Development with Yii 1.1 and PHP5Fast-track your web application development by harnessing the power of the Yii PHP FrameworkJeffery Winesett BIRMINGHAM - MUMBAI Agile Web Application Development with Yii 1.1 and PHP5Copyright © 2010 Packt PublishingAll 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 2010Production Reference: 1030810Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK.ISBN 978-1-847199-58-4www.packtpub.comCover Image by Vinayak Chittar (vinayak.chittar@gmail.com) CreditsAuthorJeffery WinesettReviewersImre MeheszJonah TurnquistKyle FerreiraAcquisition EditorUsha IyerDevelopment EditorsDhwani DevaterReshma SundaresanTechnical EditorsAditya BelpathakHyacintha D'SouzaIndexerHemangini BariEditorial Team LeaderAanchal KumarProject Team LeaderPriya MukherjiProject CoordinatorPrasad RaiProofreaderLesley HarrisonGraphicsGeetanjali SawantProduction Coordinator Melwyn D'saCover WorkMelwyn D'sa About the AuthorJeffery Winesett is the director of software engineering and application development at Control Group Inc., a New York based consulting rm specializing in delivering technology for big ideas. He has spent the last ve 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 ReviewersImre 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 ofcial 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 ContentsPreface 1Chapter 1: Meet Yii 7Yii is easy 8Yii is efcient 8Yii is extensible 9MVC architecture 9The model 10The view 10The controller 10Stitching these together: Yii request routing 11Blog posting example 11Object-relational mapping and Active Record 13Active Record 14The view and controller 14Summary 15Chapter 2: Getting Started 17Installing Yii 17Installing a database 19Creating a new application 19Hello, World! 22Creating the controller 22One nal step 26Reviewing our request routing 27Adding dynamic content 28Adding the date and time 28Adding the date and time, a better approach 29Moving the data creation to the controller 29Have you been paying attention? 30 Table of Contents[ ii ]Linking pages together 31Linking to a new page 31Getting a little help from Yii CHtml 32Summary 34Chapter 3: The TrackStar Application 35Introducing TrackStar 35Creating user stories 36Users 36Projects 36Issues 37Navigation and page ow 38Dening a data scheme 39Dening our development methodology 41Automated software testing 41Unit and functional testing 41Benets of testing 42Test-driven development 43Testing in Yii 43Unit tests 44Installing PHPUnit 45Functional tests 45Installing Selenium 45Running a quick example 46Hello TDD! 47Summary 52Chapter 4: Iteration 1: Creating the Initial TrackStar Application 53Iteration planning 53Creating the new application 54Connecting to the database 55Testing the connection 55Yii and databases 57Adding a db connection as an application component 58Summary 60Chapter 5: Iteration 2: Project CRUD 61Iteration planning 61Running our test suite 62Creating the project table 62Naming conventions 63Creating the AR model class 64Conguring Gii 65Using Gii to create our Project AR class 66 Table of Contents[ iii ]Testing out our newly generated code 68Creating the unit test le 69Testing create 69Testing read 71Testing update and delete 72Was all that testing really necessary? 73Enabling CRUD operations for users 73Creating CRUD scaffolding for projects 74Creating a new project 77Adding a required eld to our form 78Reading the project 82Updating and deleting projects 83Managing projects in admin mode 83More on testing—xtures 85Conguring the xture manager 86Creating a xture 86Conguring this xture for use 88Specifying a test database 89Using xtures 90Summary 92Chapter 6: Iteration 3: Adding Tasks 93Iteration planning 93Running the test suite 94Designing the schema 95Dening some relationships 95Building the database and the relationships 96Creating the Active Record model classes 98Creating the Issue model class 98Creating the User model class 101Creating the Issue CRUD operations 101Using the Issue CRUD operations 102Creating a new Issue 103Adding the types drop-down menu 104Getting the test in the "Red" 105Moving From "Red" To "Green" 105Moving Back To "Red" 106Getting back to "Green" once again 107Adding the issue type dropdown 107Adding the status drop-down menu: Do it yourself 111Fixing the owner and requester elds 112Enforcing a project context 112Implementing a lter 113Download from Wow! eBook <www.wowebook.com> [...]... assume the following: • YiiRoot is the folder where you have installed Yii • WebRoot is configured as the document root of your web server • From your command line, change to your WebRoot folder and execute the following: % cd WebRoot % YiiRoot/framework/yiic webapp demo Create a Web application under '/Webroot/demo'? [Yes|No] Yes mkdir /WebRoot/demo mkdir /WebRoot/demo/assets mkdir /WebRoot/demo/css generate... written in PHP 5 Yii makes it easier to create and maintain large-scale web applications It also makes them more efficient and extensible Let's take a quick look at each of these characteristics of Yii in turn Yii is easy To run a Yii- powered web application, all you need is the core framework files and a web server supporting PHP 5.1.0 or higher To develop with Yii, you only need to know PHP and object-oriented... defaults and conventions later in this chapter and throughout the book Yii is efficient Yii is a high-performance component-based framework for developing web applications on any scale It encourages maximum code reuse in web programming, and can significantly accelerate the development process As mentioned previously, if you stick with Yii' s built-in conventions, you can get your application up and running... Building a Yii application mainly involves writing and maintaining your own custom PHP classes, some of which will extend from the core Yii Framework component classes Yii incorporates many of the great ideas and work from other well-known web programming frameworks and applications So, if you are coming to Yii after using other web development frameworks, it is likely you will find it familiar and easy... generate css/main.css Your application has been created successfully under /Webroot/demo The webapp command is used to create a brand new Yii web application It takes just a single argument to specify either the absolute or relative path to the folder in which the application should be created The result is the generation of all the needed folders and files to provide a default Yii web application skeleton... are getting started All these folders and files are actually a working web application The yiic command has populated the application with enough code to establish a simple home page, a typical Contact Us page to provide an example of a web form, and a login page with enough autogenerated code to demonstrate basic authorization and authentication in Yii If your web server supports the GD2 graphics library... powerful and useful 3 The MVC application architecture and the implementation of this architecture in Yii 4 A typical Yii web request lifecycle and URL structures 5 Object-relational mapping and Active Record in Yii [ 15 ] Getting Started The real pleasures and benefits of Yii are quickly revealed by simply using it In this chapter, we will see how the concepts introduced in the previous chapter, Meet Yii, ... version is 1.1. 2 It has a growing development team and continues to gain popularity among PHP developers everyday We feel that with just a little help from the information contained in this book, you will soon understand why Meet Yii The name Yii (an acronym for Yes, it is, pronounced as Yee or [ji:]) stands for easy, efficient, and extensible Yii is a high-performance, component-based, web application. .. understand what is happening behind the scenes What this book cover Chapter 1—Meet Yii introduces Yii at a high level We learn the importance and utility of using application development frameworks, and the characteristics of Yii that make it incredibly powerful and useful Chapter 2—Getting Started walks through a simple Hello, World! style application using the Yii Framework Chapter 3—The TrackStar Application. .. up and running with little to no manual configuration Yii is also designed to help you with DRY development DRY (Don't Repeat Yourself) is a key concept of agile application development All Yii applications are built using the Model-View-Controller (MVC) architecture Yii enforces this development pattern by providing a place to keep each piece of your MVC code This minimizes duplication and helps promote . Agile Web Application Development with Yii 1. 1 and PHP5Fast-track your web application development by harnessing the power of the Yii PHP FrameworkJeffery. FrameworkJeffery Winesett BIRMINGHAM - MUMBAI Agile Web Application Development with Yii 1. 1 and PHP5Copyright © 2 010 Packt PublishingAll rights reserved. No

Ngày đăng: 03/01/2013, 08:56

TỪ KHÓA LIÊN QUAN

w