Practical Symfony
Total Page:16
File Type:pdf, Size:1020Kb
Practical symfony symfony 1.3 & 1.4 | Doctrine This PDF is brought to you by License: Creative Commons Attribution-Share Alike 3.0 Unported License Version: jobeet-1.4-doctrine-en-2011-08-18 Table of Contents ii Table of Contents About the Author............................................................................................... 9 About Sensio Labs........................................................................................... 10 Which symfony Version? ................................................................................. 11 Day 1: Starting up the Project ........................................................................ 12 Introduction ............................................................................................................. 12 This Book is different............................................................................................... 12 What for Today?....................................................................................................... 13 Prerequisites............................................................................................................ 13 Third-Party Software .......................................................................................................... 13 Command Line Interface .................................................................................................... 13 PHP Configuration.............................................................................................................. 14 Symfony Installation ................................................................................................ 14 Initializing the Project Directory ........................................................................................ 14 Choosing the Symfony Version........................................................................................... 15 Choosing the Symfony Installation Location ...................................................................... 15 Installing Symfony.............................................................................................................. 15 Project Setup ........................................................................................................... 17 Project Creation ................................................................................................................. 17 Application Creation........................................................................................................... 17 Directory Structure Rights ................................................................................................. 18 Web Server Configuration: The ugly Way ............................................................... 19 Web Server Configuration: The secure Way ........................................................... 19 Web Server Configuration.................................................................................................. 19 Test the New Configuration ............................................................................................... 20 The Environments.................................................................................................... 22 Subversion ............................................................................................................... 24 Final Thoughts......................................................................................................... 25 Day 2: The Project........................................................................................... 26 The Project Pitch ..................................................................................................... 26 The Project User Stories.......................................................................................... 27 Story F1: On the homepage, the user sees the latest active jobs ...................................... 27 Story F2: A user can ask for all the jobs in a given category............................................. 28 Story F3: A user refines the list with some keywords........................................................ 29 Story F4: A user clicks on a job to see more detailed information .................................... 29 Story F5: A user posts a job ............................................................................................... 30 Story F6: A user applies to become an affiliate ................................................................. 31 Story F7: An affiliate retrieves the current active job list.................................................. 31 Story B1: An admin configures the website ....................................................................... 32 Story B2: An admin manages the jobs................................................................................ 32 Story B3: An admin manages the affiliates ........................................................................ 32 ----------------- Brought to you by Table of Contents iii Final Thoughts......................................................................................................... 32 Day 3: The Data Model.................................................................................... 33 The Relational Model............................................................................................... 33 The Schema ............................................................................................................. 33 The Database ........................................................................................................... 36 The ORM.................................................................................................................. 36 The Initial Data ........................................................................................................ 38 See it in Action in the Browser ................................................................................ 40 Final Thoughts......................................................................................................... 42 Day 4: The Controller and the View ................................................................ 43 The MVC Architecture ............................................................................................. 43 The Layout ............................................................................................................... 44 The Stylesheets, Images, and JavaScripts ............................................................... 47 The Job Homepage................................................................................................... 50 The Action .......................................................................................................................... 50 The Template...................................................................................................................... 51 The Job Page Template ............................................................................................ 52 Slots ......................................................................................................................... 54 The Job Page Action................................................................................................. 55 The Request and the Response................................................................................ 57 The Request........................................................................................................................ 57 The Response ..................................................................................................................... 58 Final Thoughts......................................................................................................... 59 Day 5: The Routing ......................................................................................... 60 URLs ........................................................................................................................ 60 Routing Configuration ............................................................................................. 61 Route Customizations .............................................................................................. 62 Requirements........................................................................................................... 63 Route Class .............................................................................................................. 63 Object Route Class................................................................................................... 64 Routing in Actions and Templates ........................................................................... 67 Collection Route Class............................................................................................. 67 Route Debugging ..................................................................................................... 69 Default Routes ......................................................................................................... 70 Final Thoughts......................................................................................................... 70 Day 6: More with the Model............................................................................ 71 The Doctrine Query Object ...................................................................................... 71 Debugging Doctrine generated SQL ......................................................................