Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
International PHP Conference 2008   Inspiring people toFluent Development with FLOW3       share
The History of FLOW3      (short version)
The Long History of TYPO3 Since 1998 33 core members committed 500.000 lines of code resulting in a code base of 300.000 l...
TYPO3 today     TYPO3 v4 is nearly feature complete     Grown architecture, few unit tests     Fundamental changes are ris...
TYPO3 tomorrow?Fluent Development with FLOW3   Inspiring people to                                share
<?php
Buy none get two for free.Fluent Development with FLOW3   Inspiring people to                                share
TYPO3 tomorrow     FLOW3 acts as a reliable basis for any kind of web application     TYPO3 v5 is a package based on FLOW3...
The FLOW3 experience Flow [fl!] The mental state of operation in which the person is fully immersed in what he or she is d...
!   /**!     * Creates a customer!     *!     * @return void!     */!   public function createAction() {!   !     if (!$th...
!   /**!     * Creates a customer!     *!     * @return void!     */!   public function createAction() {!   !     if (!$th...
<?php!       /**!         * Creates a customer!         *!         * @return void!         */!       public function creat...
FLOW3 = Application Framework     Not just a collection of components or code snippet library     Comes with ready-to-go d...
Finest Handmade PHP Code     100% documented source code (top project at Ohloh)     Consistent and intuitive class, method...
FLOW3 modules     AOP                Locale        Reflection     Component          Log           Resource     Configuratio...
Getting StartedFluent Development with FLOW3   Inspiring people to                                share
Getting StartedRequirements       Some webserver (tested with Apache and IIS)       PHP 5.3alpha1 or higher (see http://sn...
Getting StartedDownload       Currently available through Subversion          Checkout the FLOW3 Distribution:          sv...
Fluent Development with FLOW3   Inspiring people to                                share
Getting StartedGrant File Permissions       The webserver needs          read access for all files of the distribution and ...
Getting StartedCreate a packageIn order to create a new package, just createa new folder within the Packages directory.Flu...
Getting Started     Create a Default Controller         Create a subfolder in your package: Classes/Controller/         Cr...
BootstrapFluent Development with FLOW3   Inspiring people to                                share
BootstrapPublic/index.php       This file is the default main script       It launches FLOW3 in the Production context     ...
BootstrapPublic/index_dev.php       This script is used for development       It launches FLOW3 in the Development context...
Model - View - ControllerFluent Development with FLOW3   Inspiring people to                                share
MVCKey Features      Powerful Request-Response mechanism, based on Front Controller and      Dispatcher      Very convenie...
MVCModel Types                  Active Record                               Domain Model             Model of / wrapper fo...
MVC PatternModel                   Active Record                             Domain Model              Model of / wrapper ...
MVC PatternModel                   Active Record                             Domain Model              Model of / wrapper ...
PersistenceFluent Development with FLOW3   Inspiring people to                                share
PersistenceJSR-283 based Content Repository       Defines a uniform API for accessing content repositories       A Content ...
PersistenceTransparent Persistence       Explicit support for Domain-Driven Design       Class Schemata are defined by the ...
ComponentsFluent Development with FLOW3   Inspiring people to                                share
ComponentsComponent Dependencies      Components seldomly come alone      Components depend on other components which depe...
ComponentsDependency Injection      A component doesnt ask for the instance of another      component but gets it injected...
ComponentsAutowiring      FLOW3 tries to autowire constructor arguments and      arguments of inject* methods      The typ...
DEMOFluent Development with FLOW3   Inspiring people to                                share
SecurityFluent Development with FLOW3   Inspiring people to                                share
PlaygroundFluent Development with FLOW3   Inspiring people to                                share
Things to play withF3BLOG       Try out the Blog Example:       svn co https://svn.typo3.org/FLOW3/Distribution/branches/B...
Things to play withTYPO3CR Admin       Play with persistence and watch your object in the TYPO3CR AdminFluent Development ...
Things to play withTestrunner       Experiment with Test-Driven Development and watch the tests in       FLOW3s test runne...
Progress             Developing FLOW3 ...Fluent Development with FLOW3       Inspiring people to                          ...
Next Steps     First FLOW3 alpha release end of this year     First pilot projects based on FLOW3 in spring 09     Further...
Links     These Slides     http://flow3.typo3.org/documentation/slides/     FLOW3 Website     http://flow3.typo3.org     TYP...
QuestionsFluent Development with FLOW3   Inspiring people to                                share
Fluent Development with FLOW3
Upcoming SlideShare
Loading in …5
×

Fluent Development with FLOW3

1,313 views

Published on

FLOW3 is a modern web application framework for PHP, developed as the foundation of the upcoming version of the TYPO3 CMS. It introduces new development concepts to the PHP world such as Domain-Driven Design, Dependency Injection and Aspect-Oriented Programming. In this session you&rsquo;ll get a first-hand introduction to the concepts behind FLOW3.

  • Be the first to comment

  • Be the first to like this

Fluent Development with FLOW3

  1. 1. International PHP Conference 2008 Inspiring people toFluent Development with FLOW3 share
  2. 2. The History of FLOW3 (short version)
  3. 3. The Long History of TYPO3 Since 1998 33 core members committed 500.000 lines of code resulting in a code base of 300.000 lines today
  4. 4. TYPO3 today TYPO3 v4 is nearly feature complete Grown architecture, few unit tests Fundamental changes are risky Often used as an application framework - but was designed as a CMSFluent Development with FLOW3 Inspiring people to share
  5. 5. TYPO3 tomorrow?Fluent Development with FLOW3 Inspiring people to share
  6. 6. <?php
  7. 7. Buy none get two for free.Fluent Development with FLOW3 Inspiring people to share
  8. 8. TYPO3 tomorrow FLOW3 acts as a reliable basis for any kind of web application TYPO3 v5 is a package based on FLOW3 Extensions are packages as well, all based on FLOW3 Packages can be used as extensions for TYPO3 as libraries for standalone applicationsFluent Development with FLOW3 Inspiring people to share
  9. 9. The FLOW3 experience Flow [fl!] The mental state of operation in which the person is fully immersed in what he or she is doing by a feeling of energized focus, full involvement, and success in the process of the activity. Proposed by positive psychologist Mihály Csíkszentmihályi, the concept has been widely referenced across a variety of fields. FLOW3 [fl!three] The application framework which takes care of all hassle and lets you play the fun part.Fluent Development with FLOW3 Inspiring people to share
  10. 10. ! /**! * Creates a customer! *! * @return void! */! public function createAction() {! ! if (!$this->authorizationService->getCurrentUser()->hasRole(Admin)) {! ! ! $this->logger->log(Someone tried to create a new customer.);! ! ! throw new AccessDeniedException(You may not create customers.);! ! }! ! if ($this->request->getProtocol != HTTPS) {! ! ! $this->logger->log(Someone tried to create a new customer not using HTTPS.);! ! ! throw new SecurityException(Customers may only be created via HTTPS);! ! }! !! ! if (strlen($_POST[firstname]) > 50) throw new InvalidArgumentException();! !! ! $customer = new ModelCustomer;! ! $customer->setFirstName($_POST[firstname]);! ! $customer->setLastName($_POST[lastname]);! !! ! $customerValidator = MyAppValidatorsCustomerValidator::getInstance();! ! if ($customerValidator->validate($customer)) {! ! ! $customer->save();! ! ! $this->logger->log(A new customer was saved);! ! } else {! ! ! throw new InvalidCustomerException();! ! }! } Fluent Development with FLOW3 Inspiring people to share
  11. 11. ! /**! * Creates a customer! *! * @return void! */! public function createAction() {! ! if (!$this->authorizationService->getCurrentUser()->hasRole(Admin)) {! ! ! $this->logger->log(Someone tried to create a new customer.);! ! ! throw new AccessDeniedException(You may not create customers.);! ! }! ! if ($this->request->getProtocol != HTTPS) {! ! ! $this->logger->log(Someone tried to create a new customer not using HTTPS.);! ! ! throw new SecurityException(Customers may only be created via HTTPS);! ! }! !! ! if (strlen($_POST[firstname]) > 50) throw new InvalidArgumentException();! !! ! $customer = new ModelCustomer;! ! $customer->setFirstName($_POST[firstname]);! ! $customer->setLastName($_POST[lastname]);! !! ! $customerValidator = MyAppValidatorsCustomerValidator::getInstance();! ! if ($customerValidator->validate($customer)) {! ! ! $customer->save();! ! ! $this->logger->log(A new customer was saved);! ! } else {! ! ! throw new InvalidCustomerException();! ! }! } Fluent Development with FLOW3 Inspiring people to share
  12. 12. <?php! /**! * Creates a customer! *! * @return void! */! public function createAction() {! ! if ($this->arguments->hasErrors()) $this->throwStatus(400, Bad Request, <strong>Invalid arguments!</strong>);! ! $customer = new DomainModelCustomer();! ! $this->dataMapper->map($this->arguments[customer], $customer);! ! $this->customerRepository->add($customer);! ! $this->throwStatus(201);! }?> Fluent Development with FLOW3 Inspiring people to share
  13. 13. FLOW3 = Application Framework Not just a collection of components or code snippet library Comes with ready-to-go default configuration Package based PHP 5 Runs with PHP 5.3 or later.3alpha 1 Comes with a powerful JSR-283 based Content RepositoryFluent Development with FLOW3 Inspiring people to share
  14. 14. Finest Handmade PHP Code 100% documented source code (top project at Ohloh) Consistent and intuitive class, method and variable names FLOW3 Core Team always develops test-driven Continuous Integration multiple commits each day automatic tests for Linux, Windows and Mac with SQLite, MySQL and Postgres open CI server with statistics, email and jabber notificationsFluent Development with FLOW3 Inspiring people to share
  15. 15. FLOW3 modules AOP Locale Reflection Component Log Resource Configuration MVC Security Cache Package Utility Error Persistence Validation Event Property ... and moreFluent Development with FLOW3 Inspiring people to share
  16. 16. Getting StartedFluent Development with FLOW3 Inspiring people to share
  17. 17. Getting StartedRequirements Some webserver (tested with Apache and IIS) PHP 5.3alpha1 or higher (see http://snaps.php.net/) PHP extensions: zlib, PDO and PDO SQLite and the usual stuff Some database (tested with SQLite, MySQL and Postgres)Fluent Development with FLOW3 Inspiring people to share
  18. 18. Getting StartedDownload Currently available through Subversion Checkout the FLOW3 Distribution: svn co https://svn.typo3.org/FLOW3/distribution/trunk or try the TYPO3 Distribution: svn co https://svn.typo3.org/TYPO3v5/distribution/trunk Nightly builds will follow after the 1.0 alpha 1 releaseFluent Development with FLOW3 Inspiring people to share
  19. 19. Fluent Development with FLOW3 Inspiring people to share
  20. 20. Getting StartedGrant File Permissions The webserver needs read access for all files of the distribution and write access in the Public and Data directory On Linux / Mac just call sudo ./fixpermissions.sh On legacy operating systems: ask your system administratorFluent Development with FLOW3 Inspiring people to share
  21. 21. Getting StartedCreate a packageIn order to create a new package, just createa new folder within the Packages directory.Fluent Development with FLOW3 Inspiring people to share
  22. 22. Getting Started Create a Default Controller Create a subfolder in your package: Classes/Controller/ Create the controller class file:<?phpdeclare(ENCODING = utf-8);namespace F3MyPackageController;class DefaultController extends F3FLOW3MVCControllerActionController {! public function indexAction() {! ! return Hello World!;! }}?> Fluent Development with FLOW3 Inspiring people to share
  23. 23. BootstrapFluent Development with FLOW3 Inspiring people to share
  24. 24. BootstrapPublic/index.php This file is the default main script It launches FLOW3 in the Production context The webservers web root should point to the Public directory define(FLOW3_PATH_PUBLIC, str_replace(, /, __DIR__) . /); require(FLOW3_PATH_PUBLIC . ../Packages/FLOW3/Classes/F3_FLOW3.php); $framework = new F3FLOW3(); $framework->run();Fluent Development with FLOW3 Inspiring people to share
  25. 25. BootstrapPublic/index_dev.php This script is used for development It launches FLOW3 in the Development context More scripts like this can be created for additional contexts define(FLOW3_PATH_PUBLIC, str_replace(, /, __DIR__) . /); require(FLOW3_PATH_PUBLIC . ../Packages/FLOW3/Classes/F3_FLOW3.php); $framework = new F3FLOW3(Development); $framework->run();Fluent Development with FLOW3 Inspiring people to share
  26. 26. Model - View - ControllerFluent Development with FLOW3 Inspiring people to share
  27. 27. MVCKey Features Powerful Request-Response mechanism, based on Front Controller and Dispatcher Very convenient controllers and views Supports multiple template engines Sophisticated, easy to configure routing Built-in validation and default security REST supportFluent Development with FLOW3 Inspiring people to share
  28. 28. MVCModel Types Active Record Domain Model Model of / wrapper for a Model of a domain which consists of database table row data and behaviour is responsible for persistence doesnt know about persistence mixes infrastructure concerns with model doesnt know about infrastructure quick to implement without a framework clean and easy to use if framework supports itFluent Development with FLOW3 Inspiring people to share
  29. 29. MVC PatternModel Active Record Domain Model Model of / wrapper for a Model of a domain which consists of database table row data and behaviour is responsible for persistence doesnt know about persistence mixes infrastructure concerns with model doesnt know about infrastructure quick to implement without a framework clean and easy to use if framework supports itFluent Development with FLOW3 Inspiring people to share
  30. 30. MVC PatternModel Active Record Domain Model Model of / wrapper for a Model of a domain which consists of database table row data and behaviour is responsible for persistence doesnt know about persistence mixes infrastructure concerns with model doesnt know about infrastructure quick to implement without a framework clean and easy to use if framework supports itFluent Development with FLOW3 Inspiring people to share
  31. 31. PersistenceFluent Development with FLOW3 Inspiring people to share
  32. 32. PersistenceJSR-283 based Content Repository Defines a uniform API for accessing content repositories A Content Repository is a kind of object database for storage, search and retrieval of hierarchical data provides methods for versioning, transactions and monitoring TYPO3CR is the first working port of JSR-170 / JSR-283 Karsten Dambekalns is member of the JSR-283 expert groupFluent Development with FLOW3 Inspiring people to share
  33. 33. PersistenceTransparent Persistence Explicit support for Domain-Driven Design Class Schemata are defined by the Domain Model class No need to write an XML or YAML schema definition No need to define the database model and object model multiple times at different places Automatic persistence in the JSR-283 based Content Repository Legacy data sources can be mountedFluent Development with FLOW3 Inspiring people to share
  34. 34. ComponentsFluent Development with FLOW3 Inspiring people to share
  35. 35. ComponentsComponent Dependencies Components seldomly come alone Components depend on other components which depend on other components which ... Problem: Components explicitly refer to other components: $phoneBookManager = new PhoneBookManagerFluent Development with FLOW3 Inspiring people to share
  36. 36. ComponentsDependency Injection A component doesnt ask for the instance of another component but gets it injected This methodology is referred to as the "Hollywood Principle": "Dont call us, well call you" Enforces loose coupling and high cohesion Makes you a better programmerFluent Development with FLOW3 Inspiring people to share
  37. 37. ComponentsAutowiring FLOW3 tries to autowire constructor arguments and arguments of inject* methods The type of the component to be injected is determined by the argument type (type hinting) Autowiring does not work with Setter Injection through regular setters (set* methods) Dependencies are only autowired if no argument is passed explicitlyFluent Development with FLOW3 Inspiring people to share
  38. 38. DEMOFluent Development with FLOW3 Inspiring people to share
  39. 39. SecurityFluent Development with FLOW3 Inspiring people to share
  40. 40. PlaygroundFluent Development with FLOW3 Inspiring people to share
  41. 41. Things to play withF3BLOG Try out the Blog Example: svn co https://svn.typo3.org/FLOW3/Distribution/branches/BlogExample/Fluent Development with FLOW3 Inspiring people to share
  42. 42. Things to play withTYPO3CR Admin Play with persistence and watch your object in the TYPO3CR AdminFluent Development with FLOW3 Inspiring people to share
  43. 43. Things to play withTestrunner Experiment with Test-Driven Development and watch the tests in FLOW3s test runnerFluent Development with FLOW3 Inspiring people to share
  44. 44. Progress Developing FLOW3 ...Fluent Development with FLOW3 Inspiring people to share
  45. 45. Next Steps First FLOW3 alpha release end of this year First pilot projects based on FLOW3 in spring 09 Further development of the TYPO3 package Planned release of TYPO3 5.0 alpha: end of 2009Fluent Development with FLOW3 Inspiring people to share
  46. 46. Links These Slides http://flow3.typo3.org/documentation/slides/ FLOW3 Website http://flow3.typo3.org TYPO3 Forge http://forge.typo3.org Further Reading http://flow3.typo3.org/about/principles/further-reading/Fluent Development with FLOW3 Inspiring people to share
  47. 47. QuestionsFluent Development with FLOW3 Inspiring people to share

×