Download - T3CON09 Dallas: Hitchhikersguide
T3CON09 –!Big D, USA
Hidee guesss!
Samstag, 18. April 2009
The History of FLOW3(short version)
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
The TYPO3 Family
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
TYPO3 and FLOW3FLOW3 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 applications
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
FLOW3 sub packagesAOP
Component
Configuration
Cache
Error
Locale
Log
Monitor
MVC
Object
Package
Persistence
Reflection
Resource
Session
SignalSlot
Validation
... and more
Samstag, 18. April 2009
Samstag, 18. April 2009
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
The FLOW3 experienceFlow [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.
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
FLOW3 = Application FrameworkNot just a collection of components or code snippet library
Comes with ready-to-go default configuration
Package based
Runs with PHP 5.3 or later
Comes with a powerful JSR-283 based Content Repository
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Get the FLOW experienceIntuitive APIs
Readable source code (like a book)
Consistent naming for classes, methods and properties
Focus on the essential, the framework takes care of the infrastructure
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Getting Started
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Getting Started
RequirementsSome webserver (tested with Apache and IIS)
PHP 5.3RC1 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)
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Getting Started
DownloadCurrently 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 as soon as we've set up our release mechanism
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Getting Started
Grant File PermissionsThe 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 administrator
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
DEMO
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Model - View - Controller
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
The MVC Pattern
Modelan object which contains data and business logic of a certain domain
doesn't contain any information about the presentation of that data, but rather defines the behaviour
in the FLOW3 project we prefer a special kind of model, the Domain Model
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
The MVC Pattern
Viewrepresents the display of the model on the web or another output channel
views only display data, they don't build or modify it
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
The MVC Pattern
Controllerreacts on user input, selects and manipulates the model as accordingly
selects a view and passes it the prepared model for rendering
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Action ControllerAn action controller
accepts a request
evaluates arguments
calls the action defined in the request
and adds output to the response
MVC
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Action Controller: Important MethodsActions - methods just need an "Action" suffix:public function indexAction() { … }public function deleteAction() { … }
Initialization for the whole controller:public function initializeController() { … }
Initialization before any action is called:public function initializeAction() { … }public function initializeXYAction() { … }
MVC
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Action ArgumentsArguments are defined by declaring them in the action method
Argument data types are defined by type hint and documentation
MVC
/** * Action that displays one single post * * @param \F3\Blog\Domain\Model\Post $post The post to display * @return void * @author Robert Lemke <[email protected]> */ public function showAction(\F3\Blog\Domain\Model\Post $post) {
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
DEMO
Samstag, 18. April 2009
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Domain Driven DesignA domain is the activity or business of the user
Domain Driven Design is about
focussing on the domain and domain logic
accurately mapping the domain concepts to software
forming a ubiquitous language among the project members
Samstag, 18. April 2009
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Domain Driven Design
Ubiquitous languageThe common vocabulary is an important prerequisitefor successful collaboration
Use the same words for discussion, modeling, developmentand documentation
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Domain Driven Design
Phone Book Domain Model
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Domain Driven Design
Phone Book Domain Model
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Domain Driven Design
More phone book actionsshow phone book entries
check if user may delete phone book entry
export phone book entries
log phone book actions
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Domain Driven Design
More phone book actionsshow phone book entries
check if user may delete phone book entry
export phone book entries
log phone book actions!not in the domain of a phone book
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Domain Driven Design
Layered Architecture
Presentation
Domain
Data source
Application Logic (Service Layer)
Domain Model (Domain Layer)
View
Controller
Data Mapper (part of Content Repository)
Data Source Abstraction
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Domain Driven Design
Layered Architecture
Presentation
Domain
Data source
Application Logic (Service Layer)
Domain Model (Domain Layer)
View
Controller
Data Mapper (part of Content Repository)
Data Source Abstraction
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Validation
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Validating ArgumentsAll arguments passed to an Action Controller are automatically validated
White List policy: Only registered arguments are available
Accessing the $_GET and $_POST super globals is dangerous, dirty, deprecated and will probably be intercepted in the future
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Validating ArgumentsFLOW3 comes with a bunch of built in validators:
AlphaNumeric, EmailAddress, Float, Integer, NotEmpty, Number, NumberRange, RegularExpression, UUID, Text
Custom validators can be created (especially for Domain Models)
All validators can be chained (and nested)
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
class Blog {
/** * The blog's name. Also acts as the identifier. * * @var string * @validate Alphanumeric, Length(minimum = 3, maximum = 50) * @identity */ protected $name = '';
/** * A short description of the blog * * @var string * @validate Text, Length(maximum = 150) */ protected $description = '';
Validation Rules DefinitionAll validation rules are defined by annotations in place
Additional rules may be defined programmatically
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
/** * Create action for this controller. * * @param string $emailAddress * @return string The rendered view * @author Robert Lemke <[email protected]> * @validate $emailAddress EmailAddress */ public function createAction($emailAddress) { }
Validation Rules Definition
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
DEMO
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Security
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Objects
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Managed ObjectsThe lifecycle of an object and the combination of active objects is managed by the Object ManagerThe behavior of objects in FLOW3 is configurable
Objects
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Objects
Playing with building blocksThe combination of objects used is configurable(orchestration)
The less classes know about each other the easier it is to reuse them in a variety of contexts
Create your own LEGO set by creating cleanly separated, decoupled classes!
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Objects
Class DependenciesClasses seldomly come alone
Classes depend on other classes which depend on other classes which ...
Problem:
Classes explicitly refer to other classes:$phoneBookManager = new PhoneBookManager
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Objects
Dependency InjectionA class doesn't ask for the instance of another class but gets it injectedThis methodology is referred to as the "Hollywood Principle":"Don't call us, we'll call you"
Enforces loose coupling and high cohesion
Makes you a better programmer
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Objects
Constructor without Dependency Injection /** * @var \F3\MyPackage\Model\CustomerRepository */ protected $customerRepository; /** * Constructor * * @author Robert Lemke <[email protected]> */ public function __construct() { $this->customerRepository = \F3\MyPackage\Model\CustomerRepository::getInstance(); }
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Objects
Class with Constructor Injection /** * @var \F3\MyPackage\Model\CustomerRepository */ protected $customerRepository; /** * Constructor * * @author Robert Lemke <[email protected]> */ public function __construct(\F3\MyPackage\Model\CustomerRepository $customerRepository) { $this->customerRepository = $customerRepository; }
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Objects
Class with Setter Injection /** * @var \F3\MyPackage\Model\CustomerRepository */ protected $customerRepository; /** * Injects the customer repository * * @author Robert Lemke <[email protected]> */ public function injectCustomerRepository(\F3\MyPackage\Model\CustomerRepository $customerRepository) { $this->customerRepository = $customerRepository; }
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Objects
Class with Property Injection
/** * @var \F3\MyPackage\Model\CustomerRepository * @inject */ protected $customerRepository;
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Objects
AutowiringFLOW3's framework tries to autowire constructor arguments, arguments of inject* methods and annotated properties
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 explicitly
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Objects
Fetching components manuallyAlthough Dependency Injection is strongly recommended, there might be cases in which objects need to be created or retrieved manually
Use the getComponent() method in these cases.
$component = $componentManager->getComponent($componentName, $arg1, $arg2, ...);
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Objects
Object ScopeObjects always live in a certain scope
Currently supported scopes are:
Singleton - Only one instance exists during one script run
Prototype - Multiple instances exist
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Objects
Object ScopeThe scope can be defined through
a @scope annotation in the class (recommended)
through the object configuration in aObjects.yaml file
The default scope is "Singleton"
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Objects
Creating PrototypesDependency Injection can be used in almost any case, there's no need to call getObject()But what if you need to instantiate a class within a method?
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Objects
Creating PrototypesSolution: Call the Object Factory's createObject() method
/** * Create action for this controller. * * @param string $emailAddress * @return string The rendered view * @author Robert Lemke <[email protected]> * @validate $emailAddress EmailAddress */ public function createAction($emailAddress) { $customer = $this->objectFactory->create('F3\Demo\Customer', $emailAddress); $this->customerRepository->add($customer); }
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
REST Services
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Representational State TransferStyle of network architecture principles
Mostly for building web services
Introduced in 2000 by Roy Fielding
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
RESTful PrinciplesResource-Oriented
Uniform Interface
Stateless
Accessible through a uniform interface
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
DEMO
Samstag, 18. April 2009
Inspiring people toshareDevelopment with FLOW3
Progress
Developing TYPO3 5.0 ...
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
DEMO
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Playground
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Things to play with
F3BLOGTry out the Blog Example:svn co https://svn.typo3.org/FLOW3/Distribution/branches/BlogExample/
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Things to play with
TYPO3CR AdminPlay with persistence and watch your object in the TYPO3CR Admin
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Things to play with
TestrunnerExperiment with Test-Driven Development and watch the tests inFLOW3's test runner
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
LinksFLOW3 Websitehttp://flow3.typo3.org
TYPO3 Forgehttp://forge.typo3.org
Coding Guidelineshttp://flow3.typo3.org/documentation/coding-guidelines/
Further Readinghttp://flow3.typo3.org/about/principles/further-reading/
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Further Readinghttp://flow3.typo3.org/about/principles/further-reading/
Beathttp://beat.typo3.org
Samstag, 18. April 2009
Inspiring people toshareHitchhiker's Guide to TYPO3 v5
Questions
Samstag, 18. April 2009
Samstag, 18. April 2009
Samstag, 18. April 2009