typo3 flow 2.0 in the field - webtech conference 2013

Post on 12-May-2015

6.243 Views

Category:

Technology

5 Downloads

Preview:

Click to see full reader

DESCRIPTION

Slides of the talk: "TYPO3 Flow 2.0 in the field" / webtech Conference 2013 by Patrick Lobacher (CEO typovision GmbH) / http://webtechcon.de / 29.10.2013

TRANSCRIPT

Patrick Lobacher | typovision GmbH | 29.10.2013

TYPO3 Flow 2.0 in the Field

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Agenda• What is TYPO3 Flow?

• Installation

• Base paradigms

• In the field

• What else is inside TYPO3 Flow?

• What‘s new in TYPO3 Flow?

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

What is TYPO3 Flow?

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

TYPO3 Flow is a PHP web application platform enabling developers creating excellent

web solutions.

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• Versions

• FLOW3 1.0.0 alpha1 / 02.06.2009 (started in 2005)

• FLOW3 1.0.0 / 20.10.2011

• FLOW3 1.1.0 / 24.08.2012 (Rebranding in October 2012)

• TYPO3 Flow 2.0 / 12.07.2013

• Background

• Written by the TYPO3 community from scratch

• to have a solid code base for the next generation CMS TYPO3 Neos

• Influenced by viFramework, Spring Framework, AspectJ, NanoContainer, Ruby on Rails, Symfony, QT, Doctrine and surely more

History

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• Domain Driven Design

• Aspect-Oriented Programming

• Dependency Injection

• Model-View-Controller

• Property Mapping & Validation

• Convention over Configuration

• HTTP-Support

• Resource Management

• Templating

• Security

• Session Handling

• Command Line

• Cloud ready

• Internationalization & Localization

• Error & Exception Handling

• TDD & Debugging

• Speed & Performance

Features

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• Supported operation systems

• Linux

• Mac OS X

• Windows (Vista or later)

• Supported HTTP server plattforms

• Apache 2

• NGINX

• IIS

• PHP 5.3.2 or higher

• All systems supported by Doctrine 2 ORM can be used

Requirements

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Installation

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Download of Composer (Dependency Manager for PHP)

curl -s https://getcomposer.org/installer | php

Installation

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Download of TYPO3 Flow via Composer:

composer create-project --dev --keep-vcs typo3/flow-base-distribution flow 2.0.0

Link to Document Root (which is flow/Web)

rm htdocsln -s flow/Web htdocs

(Use composer update to update installation)

Installation

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Directory structureDirectory Description

Configuration/ Application specific configuration, grouped by contexts

Data/ Persistent and temporary data, including caches, logs, resources

Web/ Public web root

flow Flow command line tool

Build/ Build files (e.g. Surf)

Packages/ Contains sub directories which in turn contain package directories

Packages/Framework/ Packages which are part of the official TYPO3 Flow distribution

Packages/Application/ Application specific packages

Packages/Libraries/ 3rd party libraries

bin/ Helper functions

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Most of the directories and files must be readable and writable for the user you're running TYPO3 Flow with. This user will usually be the same one running your web server (httpd, www-data, www or _www on most Unix based systems).

Set permissions• 1. Parameter: Shell-User• 2. Parameter: Webserver-User• 3. Parameter: Webserver-Group

sudo ./flow core:setfilepermissions patricklobacher _www _www

File permissions

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Now that the file permissions are set, all users who plan using TYPO3 Flow from the command line need to join the web server's group.

On a Linux machine this can be done (for user patricklobacher and group _www) by typing:

sudo usermod -a -G _www patricklobacher

On a Mac type

sudo dscl . -append /Groups/_www GroupMembership patricklobacher

Groups

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Assuming that you chose Apache 2 as your web server, simply create a new virtual host by adding the following directions to your Apache configuration (conf/extra/httpd-vhosts.conf on many systems; make sure it is actually loaded with Include in httpd.conf):

httpd.conf:

<VirtualHost *:80> DocumentRoot /var/apache2/htdocs/flow/Web/ ServerName flow.dev SetEnv FLOW_CONTEXT Development</VirtualHost><VirtualHost *:80> DocumentRoot /var/apache2/htdocs/flow/Web/ ServerName flow.live SetEnv FLOW_CONTEXT Production</VirtualHost><Directory /var/apache2/htdocs/flow/> AllowOverride FileInfo Options=MultiViews</Directory>

Web server configuration

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Add the following line to your /etc/hosts file (C:\windows\system32\drivers\etc\hosts on Windows):

127.0.0.1 flow.live flow.dev

Web server configuration

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Copy Settings-File:

cp Configuration/Settings.yaml.example Configuration/Settings.yaml

Edit Configuration/Settings.yaml (2 blanks indent):

TYPO3: Flow: persistence: backendOptions: host: '127.0.0.1' # adjust to your database host dbname: 'flow' # adjust to your database name user: 'root' # adjust to your database user password: 'password' # adjust to your database pass

Set up database

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

If you configured everything correctly, the following command will create the initial table structure needed by TYPO3 Flow:

./flow doctrine:migrate

Migration

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Now call the following URL in your browserhttp://flow.dev/

Testing

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Base Paradigms

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• An approach which ...

• results in rich domain models

• provides a common language (ubiquacross the project team

• simplify the design of complex applications

• The premise of TYPO3 Flow is:

• Placing the project's primary focus on the core domain and domain logic

• Basing complex designs on a model of the domain

• Introducing an ubiquitous language which concerns all assets

• TYPO3 Flow is the first PHP framework tailored to Domain-Driven Design

Domain Driven Design

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Domain Driven Design

Domain Object (Entity, Value Object)

DDD Model (incl. ubiquitous language UL)

Aggregate (Aggregate Root)

Repository

Service

Relation

Strategic Pattern (Sub-/Domain, Bounded Context, Context Map)

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

MVCModel View Controller Stack (DVC)

Model/

Repository/

Validator/

Controller/

View/

Domain/

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

In the field -a step-by-step example

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

We assume a pretty simple domain Model:

Domain Model

PostBlog

title

description

posts

title

1

n

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Let's create a new package Blog inside the vendor namespace IPC:

./flow kickstart:package IPC.Blog

If you want to have more information about the commands, you can use:

./flow help

./flow help kickstart:package

Kickstart the package

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Kickstart the package

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Now call the package:

http://flow.dev/IPC.Blog

Kickstart the package

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

If you compare with our domain model we need a controller for the Domain Model „Post“.

We also need a SetupController which initially sets up the blog. Create them with the kickstarter as well:

./flow kickstart:actioncontroller IPC.Blog Setup

Kickstart Controllers

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Kickstart PostController (and all related files):./flow kickstart:actioncontroller --generate-actions --generate-related IPC.Blog Post

Update database:./flow doctrine:update

Test them with:http://flow.dev/IPC.Blog/Setuphttp://flow.dev/IPC.Blog/Post

Kickstart Controllers

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Kickstart Blog Model:./flow kickstart:model IPC.Blog Blog title:string description:string 'posts:\Doctrine\Common\Collections\Collection'./flow doctrine:update

Kickstart Blog Model

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Kickstart Blog Model

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Edit Blog Model to look like the following(Packages/Application/IPC.Blog/Classes/IPC/Blog/Domain/Blog.php):

Edit Blog Model

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Add to Blog Model to look like the following(Packages/Application/IPC.Blog/Classes/IPC/Blog/Domain/Blog.php):

Add to Blog Model

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Kickstart Post Model:./flow kickstart:model --force IPC.Blog Post 'blog:\IPC\Blog\Domain\Model\Blog' title:string linkTitle:string date:\DateTime author:string content:string./flow doctrine:update

Kickstart Post Model

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Edit Blog Model to look like the following(Packages/Application/IPC.Blog/Classes/IPC/Blog/Domain/Post.php):

Edit Post Model

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Kickstart Blog Repository:./flow kickstart:repository IPC.Blog Blog

Kickstart Blog Repository

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• There are „magic“ methods available• add

• remove

• update

• findAll

• findBy[PropertyName]

• findOneBy[PropertyName]

• count

• countBy[PropertyName]

Repository

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Repository - Examples

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Setup - Controller - 1Edit Setup Controller to look like the following(Packages/Application/IPC.Blog/Classes/IPC/Blog/Controller/SetupController.php):./flow doctrine:update

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Setup - Controller - 2Edit Setup Controller to look like the following(Packages/Application/IPC.Blog/Classes/IPC/Blog/Controller/SetupController.php):./flow doctrine:update

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Index Action / Setup Controller

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Edit Blog Repository:

Edit Blog Repository

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Edit Post Controller:

Edit Post Controller

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Index Action / Post Controller

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

What else is inside TYPO3 Flow?

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• TYPO3 Flow has its own template engine called Fluid.

• Focus on the following features:

• Support of logical structures (such as conditions, widgets, conditions, loops, iteration over array, ...)

• No PHP code in the template file

• Easy to expand through ViewHelper (reusable)

• Simple but intuitve syntax

• Provide an XML structure for automated template validation

• Highly object oriented

Templating via Fluid

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Templating via Fluid

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Templating via Fluid

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• Object Persistence in the Flow is

• based on Doctrine 2

• integrates seamless into Flow

• provides all the great Doctrine 2 features

• provides Doctrine 2 Migrations

• uses UUIDs

• provides a low level persistence API

• allows for own, custom persistence backends (instead of Doctrine 2)

• e.g. Solr or CouchDB

Persistence

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• Loggin without AOP

Aspect oriented programming

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• Loggin with AOP

Aspect oriented programming

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• AOP is used for in TYPO3 Flow for• persistence magic

• logging

• debugging

• security

• Advices within TYPO3 Flow• @Flow\Before

• @Flow\AfterReturning

• @Flow\AfterThrowing

• @Flow\After

• @Flow\Around

Aspect oriented programming

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• as many default build-in security mechanism as possible

• CSRF protection

• SQL-Injection protection

• Cross Site Scripting (XSS) protectipn

• centrally managed through AOP

• modeled after TYPO3 CMS and Spring Security

• supports authentication, authorization, validation, filtering, security policies, ...

• can intercept arbitrary method calls

• transparently filters content through query-rewriting

• highly extensible for new authmechanisms

Security

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

And many more...

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

What is new in Flow 2.0?

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• Consider a controller which depends on 15 other services. Not all of these are used in every action. And since most of these services may in turn depend on other services which have even further dependencies, you end up loading maybe hundreds of class files which are not needed for the particular action to be executed.

• In Flow 2.0 dependencies injected through Property Injection are now "lazy" by default. Developers can uses these dependencies like before, but the instance is created and thus the class file is only loaded when the service is actually used the first time.  Apart from a few special cases this process is completely transparent to the developer.

• This will increase the speed of the application enormous

Lazy Dependency Injection

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• The HTTP 1.1 specification states that the GET and HEAD request methods should be considered "safe", which means that they should not do anything other than retrieve information.

• In Flow 2.0 we now enforce this rule by disabling the automatic persistence for "safe" request methods.

• In practice this means, for example, that simple links pointing to a "delete" action will still call that action, but the delete operation will not be persisted to the database.

• Since we know that there won't be data modifications in "safe" requests, we also don't need to protect links to these actions with CSRF tokens. Or, in other words, links to a “delete” action will not really delete anything, so applications must use another non-safe request method, like POST, if they want the change to be persisted.

Safe Request Methods

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• Flow 2.0 comes with a whole new package management layer based on Composer (https://getcomposer.org), the de-facto standard for PHP dependency management.

• Take a few minutes reading the Composer documentation and getting familiar with its concepts. While it takes a few days getting into the new workflow, you will love  how much easier it is to use third party packages now. Just look at all the third-party libraries listed on packagist.org and you’ll begin to see some of the amazing possibilities with composer.

Composer

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• While creating a Single-Sign On Client / Server solution based on Flow, we wanted to be able to access and modify remote sessions in a multi-site setup. While PHP's native session implementation does support alternative storage backends, there is no official way to modify this data, except for the currently active session.

• Flow 2.0 now provides a clean session mechanism written in pure PHP. Instead of creating a whole new API for the storage, we chose to just rely on Flow's caching framework: that way you can store session data in the file system, APC, Memcache, Redis, PDO compatible databases and more.

• The Session Manager now provides additional functions to retrieve arbitrary sessions by identifier or by tags. This way it is possible to tag a session, for example, with a customer number and allow a support team have a closer look at possible problems or even log out a user remotely.

Session

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• Various changes added even better support for creating and consuming RESTful web services.

• One important change introduces support for HTTP Method Tunneling: in situations where it is not possible to send a true DELETE or PUT request (or any other request type), it is now possible simulate the request method by sending a POST request either with a "__method" argument or with a special HTTP request header.

REST Support

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Links

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Patrick Lobacher• 43 years, happily married, residing in Munich• Author of 9 books and > 40 articles on the subject of TYPO3

and web development• Active in the web deveopment area since 1994• Certified TYPO3 Integrator since 2009• Until 2012 member of the teams Extbase (Leader),

Certification and Content editoral• Until 2012 member of the EAB (Expert Advisory Board)• Co-Organizer of the TYPO3camp Munich (2008-2013) and

TYPO3 Developer Days (T3DD12)• Speaker at national and internation conferences• Lecturer for leading training institutes and MVHS

Publications:

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

• Full service digital communications agency based in Munich & NRW• >40 employees (+ 15 from freelancer pool)• CEO: Sebastian Böttger (CTO), Patrick Lobacher (CMO)• Highly specialized in TYPO3 since 10 years (Extbase/Fluid since 2009)• Platinum TYPO3 Association Member since 3 Jahren• Specialized in Enterprise Search (Solr, Elastic Search) since 3 years • Focus: Premium Open Source Web Technlologies and CMS• Agency profil (german): www.typovision.de/dieagentur

• More than 600 projects of any size

• Vision:We are the partner of our clients in all areas of its digital communication - from the initial vision to the successful implementation and far beyond.

typovision GmbH

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Customers

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Contact

Traditional:

typovision GmbH

Elsenheimerstr. 780687 Munich

Phone: +49 89 45 20 59 3 - 0Fax: +49 89 45 20 59 3 - 29

Email: info@typovision.deWeb: www.typovision.de

Twitter: www.twitter.com/typovisionwww.twitter.com/PatrickLobacherwww.twitter.com/crosscontent

Facebook: www.facebook.com/typovision

Blog:typoblog.de

Trainings:academy.typovision.de

XING: www.xing.com/companies/typovisiongmbhwww.xing.com/profile/Patrick_Lobacherwww.xing.com/profile/Sebastian_Boettger2

LinkedInwww.linkedin.com/company/2038844

Slideshare: www.slideshare.net/plobacherwww.slideshare.net/typovision

Amazon: www.amazon.de/Patrick-Lobacher/e/B0045AQVEA

Patrick Lobacher | typovision GmbH | 29.10.2013 | TYPO3 Flow in the field

Thanks a lot!

top related