
EASY PHP WEBSITES WITH THE ZEND FRAMEWORK Master the popular Zend Framework by following along with the creation of a social networking website for the video gaming community. by W. Jason Gilmore Easy PHP Websites with the Zend Framework W. Jason Gilmore Easy PHP Websites with the Zend Framework 2 Easy PHP Websites with the Zend Framework W. Jason Gilmore Copyright © 2011 W. Jason Gilmore Acknowledgements Whew. Although I recently celebrated the tenth anniversary of the publication of my first book, and have somehow managed to pen six more since, this process really isn't any easier than when I put my very first words to paper back in 2000. Writing anything, let alone books about fast moving technology, is a difficult, tedious, and often frustrating process. Yet paradoxically writing this particular book has also a deeply gratifying experience, particularly because it's a major update to the very first book published through my namesake company W.J. Gilmore, LLC back in early 2009. In the years since I've had the pleasure of communicating directly with thousands of readers around the globe, and although the self-publishing process has been occasionally a rocky road, the experience has been nothing short of extraordinary. This particular project has been a difficult one, notably because it's actually comprised of two major projects, including the book and the companion GameNomad project. Throughout, I've been very keen on trying to do things the right way, both in my writing and the process used to develop a proper Zend Framework website complete with an emphasis on models, testing, and other best practices such as deployment. In terms of acknowledgements, I'd like to make special mention of the people and teams who have (most of them unknowingly) had a major influence on this book. Thanks to project lead Matthew Weier O'Phinney and the rest of the Zend Framework team for putting together a truly fantastic web framework solution. Sebastian Bergmann for his work on PHPUnit, and EdgeCase co-founder and friend Joe O'Brien for his steadfast advocacy of test-driven development. Andreas Aderhold, Michiel Rook, and the rest of the Phing team. Martin Fowler for his amazing book "Patterns of Enterprise Application Architecture". The entire Doctrine team for what is easily one of the coolest PHP technologies on the planet. Capistrano creator Jamis Buck. The GitHub crew. Bob Stayton for his amazing patience and boundless Docbook knowledge. This list could literally go on for pages, as the number of great programmers who have influenced my thinking particularly in recent years seems infinite. Last but certainly not least, I'd also like to thank you dear readers, each and every one of you mean more to me than you'll ever know. Jason Gilmore Columbus, Ohio March 8, 2011 [email protected] Table of Contents Introduction ............................................................................................................... x The Web Ain't What It Used to Be ............................................................................ x Book Contents ....................................................................................................... x Chapter 1. Introducing Framework-Driven Development ........................................... xi Chapter 2. Creating Your First Zend Framework Project ........................................... xi Chapter 3. Managing Layouts, Views, CSS, Images, and JavaScript ............................ xi Chapter 4. Managing Configuration Data ............................................................... xi Chapter 5. Creating Web Forms with Zend_Form .................................................... xi Chapter 6. Talking to the Database with Zend_Db .................................................. xii Chapter 7. Integrating Doctrine 2 ........................................................................ xii Chapter 8. Managing User Accounts .................................................................... xii Chapter 9. Creating Rich User Interfaces with JavaScript and Ajax ............................ xii Chapter 10. Integrating Web Services .................................................................. xiii Chapter 11. Unit Testing Your Zend Framework Application ................................... xiii Chapter 12. Deploying Your Website with Capistrano ............................................ xiii Reader Expectations ............................................................................................. xiii About the Companion Project ................................................................................ xiv About the Author ................................................................................................. xiv Contact the Author ............................................................................................... xiv 1. Introducing Framework-Driven Development ............................................................. 15 Introducing the Web Application Framework ............................................................. 15 Frameworks Support the Development of Dynamic Websites .................................... 16 Frameworks Alleviate Overhead Associated with Common Activities ......................... 19 Frameworks Provide a Variety of Libraries ............................................................ 21 Test Your Knowledge ............................................................................................ 23 2. Creating Your First Zend Framework Project ............................................................. 24 Downloading and Installing the Zend Framework ....................................................... 24 Configuring the zf Tool ..................................................................................... 25 Creating Your First Zend Framework Project ............................................................. 26 Adjust Your Document Root ............................................................................... 26 Navigate to the Project Home Page ...................................................................... 29 The Project Structure ............................................................................................. 30 Extending Your Project with Controllers, Actions, and Views ....................................... 31 Creating Controllers .......................................................................................... 32 Creating Actions ............................................................................................... 33 Creating Views ................................................................................................. 33 Easy PHP Websites with the Zend Framework iii Passing Data to the View ....................................................................................... 34 Retrieving GET and POST Parameters ..................................................................... 34 Retrieving GET Parameters ................................................................................ 35 Retrieving POST Parameters ............................................................................... 36 Creating Custom Routes ......................................................................................... 36 Defining URL Parameters .................................................................................. 38 Testing Your Work ............................................................................................... 39 Verifying Controller Existence ............................................................................ 40 Verifying Action Existence ................................................................................. 40 Verifying a Response Status Code ....................................................................... 41 Test Your Knowledge ............................................................................................ 41 3. Managing Layouts, Views, CSS, Images and JavaScript ............................................... 42 Managing Your Website Layout .............................................................................. 42 Using Alternative Layouts .................................................................................. 44 Disabling the Layout ......................................................................................... 45 Managing Views ................................................................................................... 45 Overriding the Default Action View ..................................................................... 45 Disabling the View ........................................................................................... 46 View Helpers ....................................................................................................... 46 Managing URLs ............................................................................................... 46 Creating Custom View Helpers ........................................................................... 48 Managing Images .................................................................................................. 51 Managing CSS and JavaScript ................................................................................. 51 Testing Your Work ............................................................................................... 51 Verifying Form Existence ..................................................................................
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages236 Page
-
File Size-