getting into flow3 (dpc12)

Download Getting Into FLOW3 (DPC12)

Post on 19-May-2015

1.664 views

Category:

Technology

3 download

Embed Size (px)

DESCRIPTION

FLOW3 is a web application platform which uses Domain-Driven Design as its major underlying concept. This approach makes FLOW3 easy to learn and at the same time clean and flexible for complex projects. It features namespaces, has an emphasis on clean, object-oriented code and provides a seemless Doctrine 2 integration.FLOW3 incorporates Dependency Injection in a way which lets you truly enjoy creating a stable and easy-to-test application architecture (no configuration necessary). Being the only Aspect-Oriented Programming capable PHP framework, FLOW3 allows you to cleanly separate cross-cutting concerns like security from your main application logic.This tutorial takes you through an imaginary project from scratch. During the journey we’ll visit all important areas of the framework.

TRANSCRIPT

  • 1. Robert LemkeGetting intoFLOW3

2. Robert Lemkeproject founder of FLOW3 and TYPO3 Phoenixco-founder of the TYPO3 Associationcoach, coder, consultant36 years oldlives in Lbeck, Germany1 wife, 2 daughters, 1 espresso machinelikes drumming 3. StartersInstallationKickstart & Hello World!Controller, Actions, Arguments & HTTPDomain-Driven DesignDoctrineForms, Validation 4. Main DishesResources, Image UploadSession HandlingUser, Account, AuthenticationAuthorization 5. Deserts Caching Testing Logging Deployment Signal-Slot I18n Routing Espresso 6. ? 7. At a GlanceFLOW3 is a web application platform holistic concept for your apps modular, extensible, package based pedantically clean with focus on quality puts a smile on developers faces free & Open Source (LGPL v3) backed by one of the largest Open Source projects 8. Foundation for the Next Generation CMSTYPO3 Phoenix is the all-newEnterprise CMS content repository, workspaces, versions, i18n, modular UI ... powered by FLOW3 compatible code base use TYPO3 features in FLOW3 standalone apps as you like 9. FLOW3 Website and Download# 10. Git Clone$ git clone --recursive git://git.typo3.org/FLOW3/Distributions/Base.git .Cloning into ....remote: Counting objects: 3837, done.remote: Compressing objects: 100% (2023/2023), done.remote: Total 3837 (delta 2007), reused 2721 (delta 1465)Receiving objects: 100% (3837/3837), 3.49 MiB | 28 KiB/s, done.Resolving deltas: 100% (2007/2007), done. 11. Set File Permissions$ sudo ./flow3 core:setfilepermissions robert _www _wwwFLOW3 File Permission ScriptChecking permissions from here upwards.Making sure Data and Web/_Resources exist.Setting file permissions, trying to set ACLs via chmod ...Done.Linux:$ sudo usermod -a -G www-data robertMac OS X:$ sudo dscl . -append /Groups/_www GroupMembership robert 12. Set Up Database ConnectionConguration/Settings.yaml # # # Global Settings # # # TYPO3: FLOW3: persistence:backendOptions:dbname: demouser: demopassword: passwordhost: 127.0.0.1# only on Windows:core:phpBinaryPathAndFilename: C:/path/to/php.exe 13. Set Up Virtual HostApache Virtual Host DocumentRoot /opt/local/apache2/htdocs/Talks/FLOW3/Web/ ServerName dev.flow3.rob SetEnv FLOW3_CONTEXT Development DocumentRoot /opt/local/apache2/htdocs/Talks/FLOW3/Web/ ServerName flow3.rob SetEnv FLOW3_CONTEXT Production 14. Final Check 15. C lo ne t h e Be a s t 5 11 1Ro bert Lem ke D.P. F l u x t rtime (); 16. Biggest Book Store: Amazon 17. Biggest River: Amazon River Google 18. Smallest River: Roe River Google 19. Smallest River: Roe River Google 20. Smallest River: Roe River Google 21. Smallest River: Roe River 22. Smallest Book Store: Roe Books 23. Sketchy Model 24. Jus t C o de a Sh o p 521 1 Ro bert Lem keD.P. F l u x t r time (); 25. Tackling the Heart of Software Development /**Domain-Driven Design* A Book** @FLOW3Scope(protot ype)* @FLOW3EntityA methodology which ... */class Book { results in rich domain models/** * @var string */ provides a common language protected $title; across the project team /*** @var string*/ simplify the design of complex protected $isbn; applications /*** @var string*/ protected $description ;FLOW3 is the rst PHP framework /**tailored to Domain-Driven Design* @var integer*/ protected $price; 26. Domain-Driven DesignDomain activity or business of the userDomain-Driven Design is about focussing on the domain and domain logic accurately mapping the concepts to software forming a ubiquitous language among the project members 27. Domain-Driven DesignUbiquitous Language important prerequisite for successful collaboration use the same words for discussion modeling development documentation 28. Domain-Driven DesignBuilding Blocks Entity: An object that is not dened by its attributes, but rather by a thread of continuity and its identity. Value Object: An object that contains attributes but has no conceptual identity. They should be treated as immutable. Aggregate: A collection of objects that are bound together by a root entity, otherwise known as an aggregate root. The aggregate root guarantees the consistency of changes being made within the aggregate by forbidding external objects from holding references to its members. 29. Domain-Driven DesignBuilding Blocks Service: When an operation does not conceptually belong to any object. Following the natural contours of the problem, you can implement these operations in services. Repository: methods for retrieving domain objects should delegate to a specialized Repository object such that alternative storage implementations may be easily interchanged. 30. Domain-Driven Design 31. Object ManagementFLOW3s take on Dependency Injection one of the rst PHP implementations (started in 2006, improved ever since) object management for the whole lifecycle of all objects no unnecessary conguration if information can be gatered automatically (autowiring) intuitive use and no bad magical surprises fast! (like hardcoded or faster) 32. Constructor Injectionnamespace AcmeDemoController;use TYPO3FLOW3MvcControllerActionController;use AcmeDemoServiceGreeterService;class DemoController extends ActionController { /*** @var AcmeDemoServiceGreeterService*/ protected $greeterService; /** * @param AcmeDemoServiceGreeterService */ public function __construct(GreeterService $greeterService) { $this->greeterService = $greeterService; }/*** @param string $name*/public function helloAction($name) { return $this->greeterService->greet($name);}} 33. Setter Injectionnamespace AcmeDemoController;use TYPO3FLOW3MVCControllerActionController;use AcmeDemoServiceGreeterService;class DemoController extends ActionController { /*** @var AcmeDemoServiceGreeterService*/ protected $greeterService; /** * @param AcmeDemoServiceGreeterService */ public function injectGreeterService(GreeterService $greeterService) { $this->greeterService = $greeterService; }/** * @param string $name */public function helloAction($name) { return $this->greeterService->greet($name);}} 34. Property Injectionnamespace TYPO3DemoController;use TYPO3FLOW3Annotations as FLOW3;use TYPO3FLOW3MVCControllerActionController;use AcmeDemoServiceGreeterService;class DemoController extends ActionController { /** * @var TYPO3DemoServiceGreeterService * @FLOW3Inject */ protected $greeterService;/*** @param string $name*/public function helloAction($name) { return $this->greeterService->greet($name);}} 35. Objects.yaml TYPO3FLOW3SecurityCryptographyRsaWalletServiceInterface: className: TYPO3FLOW3SecurityCryptographyRsaWalletServicePhp scope: singleton properties: keystoreCache: object: factoryObjectName: TYPO3FLOW3CacheCacheManager factoryMethodName: getCache arguments: 1:value: FLOW3_Security_Cryptography_RSAWallet 36. Object Managementclass Customer { /*** @FLOW3Inject* @var AcmeCustomerNumberGenerator*/ protected $customerNumberGenerator;...}$customer = new Customer();$customer->getCustomerNumber(); 37. Object Management