• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Fluent Development with FLOW3
 

Fluent Development with FLOW3

on

  • 1,164 views

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 ...

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’ll get a first-hand introduction to the concepts behind FLOW3.

Statistics

Views

Total Views
1,164
Views on SlideShare
1,132
Embed Views
32

Actions

Likes
0
Downloads
2
Comments
0

2 Embeds 32

http://flow3.typo3.org 23
http://flow.typo3.org 9

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Fluent Development with FLOW3 Fluent Development with FLOW3 Presentation Transcript

    • 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 lines today
    • 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
    • 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 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
    • 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
    • ! /**! * 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
    • ! /**! * 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
    • <?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
    • 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
    • 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
    • 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
    • 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://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
    • 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
    • Fluent Development with FLOW3 Inspiring people to share
    • 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
    • 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
    • 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
    • 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 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
    • 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
    • Model - View - ControllerFluent Development with FLOW3 Inspiring people to share
    • 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
    • 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
    • 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
    • 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
    • PersistenceFluent Development with FLOW3 Inspiring people to share
    • 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
    • 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
    • ComponentsFluent Development with FLOW3 Inspiring people to share
    • 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
    • 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
    • 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
    • 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/BlogExample/Fluent Development with FLOW3 Inspiring people to share
    • Things to play withTYPO3CR Admin Play with persistence and watch your object in the TYPO3CR AdminFluent Development with FLOW3 Inspiring people to share
    • Things to play withTestrunner Experiment with Test-Driven Development and watch the tests in FLOW3s test runnerFluent Development with FLOW3 Inspiring people to share
    • Progress Developing FLOW3 ...Fluent Development with FLOW3 Inspiring people to share
    • 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
    • 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
    • QuestionsFluent Development with FLOW3 Inspiring people to share