TYPO3 Flow 2.0 (International PHP Conference 2013)

4,649 views

Published on

Just one year after its 1.0 release, TYPO3 Flow (formerly known as FLOW3) raises the version number to introduce a couple of new major features. In this session you’ll get a compact introduction into the comprehensive Composer support, automatic code migration, distributed session handling and new features coming up in the next version of Flow.

Published in: Technology
  • Excellent Presentation!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

TYPO3 Flow 2.0 (International PHP Conference 2013)

  1. 1. Robert Lemke_2.0
  2. 2. TEXT HEREproject founder of TYPO3 Flow and TYPO3 Neosco-founder of the TYPO3 Associationcoach, coder, consultant37 years oldlives in Lübeck, Germany1 wife, 2 daughters, 1 espresso machinelikes drumming
  3. 3. 2005
  4. 4. 2.0
  5. 5. 72 new major features236 improvements177 bug fixes
  6. 6. Speed
  7. 7. FLOW3 1.1
  8. 8. Uncached Welcome Screen
  9. 9. Uncached Welcome Screen
  10. 10. Flow 2.0 beta 3
  11. 11. 26 msUncached Welcome Screen27 ms
  12. 12. Composer
  13. 13. $ curl -s https://getcomposer.org/installer | php$ sudo mv composer.phar /usr/local/bin/composer
  14. 14. $ composer create-project --stability="beta" --dev typo3/flow-base-distribution
  15. 15. Composer is aDevelopment Tool
  16. 16. ApplicationMy Flow AppAcme.DemoClassesConfigurationNative Flow PackageControllerHelloWorldController.phpCoolProductController.phpAwesomeSauceController.phpMediocreCoffeeController.phpDomain……PackagesResources
  17. 17. LibrariesMy Flow AppsymfonyyamlSymfonyStandalone Packagecomposer.jsonDumper.phpEscaper.phpParser.phpPackagesComponentYaml phpunit.xml.distREADME.MDimaginedoctrine
  18. 18. http://bit.ly/flow-composer-video
  19. 19. NativeSessions
  20. 20. written in pure PHPbased on our HTTP foundation
  21. 21. for the cloud
  22. 22. /*** @FlowInject* @var TYPO3FlowSessionSessionManagerInterface*/protected $sessionManager;…$session = $this->sessionManager->getCurrentSession();$session->isStarted();$session->getId();
  23. 23. $session->putData(username, robert);$session->hasKey(username);$username = $session->getData(username);
  24. 24. $session = $this->sessionManager->getSession($sessionId);$username = $session->getData(username);
  25. 25. $session->addTag(user12345);…$session = $this->sessionManager->getSessionByTag(user12345);
  26. 26. Caches.yaml:Flow_Session_Storage:backend: TYPO3FlowCacheBackendApcBackend
  27. 27. based on Flow cache system
  28. 28. 404, 505
  29. 29. TYPO3:Flow:error:exceptionHandler:defaultRenderingOptions: []renderingGroups:notFoundExceptions:matchingStatusCodes: [404]options:templatePathAndFilename: resource://TYPO3.Flow/Private/Templates/Evariables:errorDescription: Sorry, the page you requested was not found.databaseConnectionExceptions:matchingExceptionClassNames: [TYPO3FlowPersistenceDoctrineDatabaoptions:templatePathAndFilename: resource://TYPO3.Flow/Private/Templates/Evariables:errorDescription: Sorry, the database connection couldnt be es
  30. 30. PersistedRoles
  31. 31. roles:User: []Manager: [User]Editor: [User, TYPO3.Neos:Editor]
  32. 32. $role = $this->policyService->createRole(Vendor.Package:Role);$this->policyService->hasRole(Vendor.Package:Role);$role = $this->policyService->getRole(Vendor.Package:Role);
  33. 33. SafeRequestMethods
  34. 34. Network Working Group R. FieldingRequest for Comments: 2616 UC IrvineObsoletes: 2068 J. GettysCategory: Standards Track Compaq/W3CJ. MogulCompaqH. FrystykW3C/MITL. MasinterXeroxP. LeachMicrosoftT. Berners-LeeW3C/MITJune 1999Hypertext Transfer Protocol -- HTTP/1.1Status of this MemoThis document specifies an Internet standards track protocol for theInternet community, and requests discussion and suggestions forimprovements. Please refer to the current edition of the "Internet
  35. 35. 9.1 Safe and Idempotent Methods9.1.1 Safe MethodsImplementors should be aware that the software represents the user intheir interactions over the Internet, and should be careful to allow theuser to be aware of any actions they might take which may have anunexpected significance to themselves or others.In particular, the convention has been established that the GET and HEADmethods SHOULD NOT have the significance of taking an action other thanretrieval. These methods ought to be considered "safe". This allows useragents to represent other methods, such as POST, PUT and DELETE, in aspecial way, so that the user is made aware of the fact that a possiblyunsafe action is being requested.Naturally, it is not possible to ensure that the server does not generateside-effects as a result of performing a GET request; in fact, somedynamic resources consider that a feature. The important distinction hereis that the user did not request the side-effects, so therefore cannot beheld accountable for them.9.1.2 Idempotent Methods
  36. 36. no automatic persistence
  37. 37. speeds up link generation
  38. 38. StaticMethodCompilation
  39. 39. /*** Returns a map of action method names and their parameters.** @return array Array of method parameters by action name*/public function getActionMethodParameters() {$methodParameters = $this->reflectionService->getMethodParameters(get_class($this), $this->actionMethodName);foreach ($methodParameters as $parameterName => $parameterInfo) {...}return $methodParameters;}}
  40. 40. /*** @return integer*/public function getNumberOfMethods() {return $class_methods = get_class_methods(myclass);}
  41. 41. /*** @return integer* @FlowCompileStatic*/public function getNumberOfMethods() {return $class_methods = get_class_methods(myclass);}
  42. 42. /*** @return integer* @FlowCompileStatic*/public function getNumberOfMethods() {return $class_methods = get_class_methods(myclass);}
  43. 43. /*** @return integer*/public function getNumberOfMethods() {return 42;}
  44. 44. LazyDependencyInjection
  45. 45. class BookController extends ActionController {/*** @FlowInject* @var BookRepository*/protected $bookRepository;}
  46. 46. class BookController extends ActionController {…public function myAction() {// $this->bookRepository is instance of Dependency Proxy$this->bookRepository->findAll();// $this->bookRepository is the real BookRepository}}
  47. 47. class BookController extends ActionController {/*** @FlowInject(lazy = false)* @var BookRepository*/protected $bookRepository;}
  48. 48. // $this->bookRepository is maybe instance of Dependency Proxyif ($this->bookRepository instanceof DependencyProxy) {$this->bookRepository->_activateDependency();}// $this->bookRepository is the real BookRepository$this->otherService->otherMethod($this->bookRepository);
  49. 49. 2.1
  50. 50. Cloud Resources
  51. 51. resource:# Definition of resource storages provided by the Flow core.# Storages are used for storing and retrieving resources.storages:#defaultPersistentResourcesStorage:storage: TYPO3FlowResourceStorageFileSystemStoragestorageOptions:path: %FLOW_PATH_DATA%Persistent/Resources/# Definition of the default resource collections.# Collections are used to bundle / group static or persistent resources# for common processing and publication.collections:# Collection which contains all persistent resourcespersistentResources:sources:-storage: defaultPersistentResourcesStoragetarget: localWebDirectoryPersistentResourcesTarget# Definition of the basic resource publication targets.targets:# Target for publishing persistent resources to the local web directorylocalWebDirectoryPersistentResourcesTarget:target: TYPO3FlowResourceTargetFileSystemTargettargetOptions:path: %FLOW_PATH_WEB%_Resources/Persistent/baseUri: _Resources/Persistent/mirrorMode: link
  52. 52. Minifying & Filters
  53. 53. Routing: Request Methods
  54. 54. 2.2
  55. 55. Page Cache & Reverse Proxy
  56. 56. Multi Persistence
  57. 57. neos.typo3.org
  58. 58. Questions?
  59. 59. inspiring-flow.com
  60. 60. TYPO3 Flow Trainings andInhouse Workshops
  61. 61. Robert Lemke_robertlemke.com@robertlemke
  62. 62. LazyDependencyInjectionBehind theScenes
  63. 63. class BookController extends ActionController {/*** @FlowInject* @var BookRepository*/protected $bookRepository;}
  64. 64. class BookController extends ActionController {…public function myAction() {// $this->bookRepository is instance of Dependency Proxy$this->bookRepository->findAll();// $this->bookRepository is the real BookRepository}}
  65. 65. $greet = function($name) {printf("Hello %s", $name);};$greet(World);
  66. 66. class BookController extends BookController_Originalimplements ProxyInterface {/*** Autogenerated Proxy Method*/public function __construct() {$this->Flow_Proxy_injectProperties();}
  67. 67. $bookRepository_reference = &$this->bookRepository;$this->bookRepository =Bootstrap::$staticObjectManager->getLazyDependencyByHash(d0e87f8f658d7866eec63db44a6918b4, $bookRepository_reference);if ($this->bookRepository === NULL) {$this->bookRepository = Bootstrap::$staticObjectManager->createLazyDependency(d0e87f8f658d7866eec63db44a6918b4, $bookRepository_reference,RobertLemkeExampleBookshopDomainRepositoryBookRepository,function() {return Bootstrap::$staticObjectManager->get(RobertLemkeExampleBookshopDomainRepositoryBookRepository);});}
  68. 68. class BookController extends ActionController {…public function myAction() {$this->bookRepository->findAll();}}
  69. 69. class DependencyProxy {…/*** Proxy magic call method which triggers the injection of the real dependency* and returns the result of a call to the original method in the dependency** @param string $methodName Name of the method to be called* @param array $arguments An array of arguments to be passed to the method* @return mixed*/public function __call($methodName, array $arguments) {return call_user_func_array(array($this->_activateDependency(), $methodName),$arguments);}/*** Activate the dependency and set it in the object.** @return object The real dependency object* @api*/public function _activateDependency() {$realDependency = $this->builder->__invoke();foreach($this->propertyVariables as &$propertyVariable) {$propertyVariable = $realDependency;}return $realDependency;}

×