flow3 - forge.typo3.org · pdf filecoding guidelines ... although we created flow3 as the...

Download FLOW3 - forge.typo3.org · PDF fileCoding Guidelines ... Although we created FLOW3 as the foundation for the TYPO3 Content Management System,

If you can't read please download the document

Upload: truongnhan

Post on 05-Feb-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • FLOW3Robert Lemke

  • FLOW3Robert LemkeCopyright 2007, 2008, 2009 Robert Lemke

    Abstract

    FLOW3 is a modern application framework for enterprise-grade PHP applications. This referencedescribes FLOW3's main features.

  • iv

    Table of Contents1. FLOW3 .................................................................................................................. 1

    1. Introduction .................................................................................................... 11.1. Overview ............................................................................................. 1

    2. FLOW3 Bootstrap .......................................................................................... 22.1. Application Context .............................................................................. 22.2. Boot Sequence .................................................................................... 2

    3. Packages ....................................................................................................... 23.1. Files and Locations ............................................................................. 33.2. Package Keys ..................................................................................... 43.3. Importing and Installing Packages ........................................................ 43.4. Package Manager ............................................................................... 53.5. Creating a New Package ..................................................................... 53.6. Package Meta Information ................................................................... 5

    4. Object Framework .......................................................................................... 64.1. Creating Objects .................................................................................. 74.2. Object Registration and API ............................................................... 114.3. Object dependencies ......................................................................... 124.4. Configuring objects ............................................................................ 16

    5. Configuration Framework .............................................................................. 225.1. Configuration Files ............................................................................. 225.2. Defining Configuration ........................................................................ 235.3. Accessing Configuration ..................................................................... 25

    6. Resource Manager ....................................................................................... 267. MVC Framework .......................................................................................... 27

    7.1. Introduction ....................................................................................... 277.2. Request and Response ...................................................................... 307.3. Controller .......................................................................................... 317.4. View ................................................................................................. 327.5. Helpers ............................................................................................. 327.6. Model ................................................................................................ 327.7. Routing ............................................................................................. 327.8. CLI request handling .......................................................................... 32

    8. Cache Framework ........................................................................................ 339. Error and Exception Handling ....................................................................... 3310. AOP Framework ......................................................................................... 33

    10.1. Introduction ...................................................................................... 3310.2. Aspects ........................................................................................... 3610.3. Pointcuts ......................................................................................... 3710.4. Declaring advice .............................................................................. 4010.5. Implementing advice ........................................................................ 4110.6. Introductions .................................................................................... 4310.7. Implementation details ...................................................................... 44

    11. Persistence Framework ............................................................................... 4511.1. Introductory Example ....................................................................... 4511.2. On the priciples of DDD ................................................................... 4611.3. Persistence-related annotations ........................................................ 4711.4. Inside the Persistence Framework .................................................... 47

    A. Coding Guidelines ................................................................................................ 491. Coding Guidelines ........................................................................................ 49

    1.1. Code formatting and layout ................................................................ 491.2. Documentation .................................................................................. 551.3. Coding .............................................................................................. 59

  • v

    List of Figures1.1. Model-View-Controller Pattern ............................................................................ 271.2. Example of a Web Request-Response Workflow ................................................. 301.3. Control flow of an advice chain .......................................................................... 421.4. Proxy building process ....................................................................................... 441.5. The objects of the Blog domain model ................................................................ 451.6. Object persistence process ................................................................................ 481.7. Object querying and reconstitution process ......................................................... 48

  • vi

    List of Tables1.1. Supported scopes ............................................................................................... 71.2. Persistence-related code annotations .................................................................. 47

  • vii

    List of Examples1.1. Package.xml ........................................................................................................ 61.2. Retrieving the Object Factory through dependency injection ................................... 81.3. A simple address book ........................................................................................ 91.4. Passing constructor arguments ........................................................................... 101.5. Sample class with lifecycle methods ................................................................... 111.6. A simple example for Constructor Injection .......................................................... 131.7. Objects.yaml file for Constructor Injection ............................................................ 131.8. A simple example for Setter Injection .................................................................. 131.9. Objects.yaml file for Setter Injection .................................................................... 131.10. The preferred way of Setter Injection, using an inject method .............................. 141.11. Example for the magic injectSettings method ..................................................... 151.12. Marking a setter-injected dependency as optional .............................................. 151.13. Sample Objects.yaml file .................................................................................. 161.14. Sample Objects.php file ................................................................................... 171.15. Sample scope annotation ................................................................................. 171.16. A simple Greeter class ..................................................................................... 181.17. Code using the object F3_MyPackage_Greeter ................................................. 181.18. Objects.yaml file for object replacement ............................................................ 181.19. The Greeter object type ................................................................................... 181.20. Code using the object type F3\MyPackage\GreeterInterface ............................... 181.21. Objects.yaml file for object type definition .......................................................... 191.22. Sample class for Constructor Injection .............................................................. 191.23. Sample configuration for Constructor Injection ................................................... 191.24. Sample class for Setter Injection ...................................................................... 201.25. Sample configuration for Setter Injection ........................................................... 201.26. Injecting an object specified in the settings ........................................................ 201.27. Example Settings.yaml of MyPa