Top Banner
T3CON07 – Karlsruhe, Germany Development with TYPO3 5.0
73

Development with TYPO3 5.0

Sep 03, 2014

Download

Documents

Robert Lemke

This session from the TYPO3 Conference 2007 gives you a peek into the current development state of the TYPO3 Framework and its main features such as Aspect Oriented Programming, Dependency Injection and the Model View Controller Framework. Bottom line of all development with 5.0 is: Domain Driven Design.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Development with TYPO3 5.0

T3CON07 – Karlsruhe, Germany

Development with TYPO3 5.0

Page 2: Development with TYPO3 5.0

Inspiring people toshare

Brought your own towel?

A towel is about the most useful thingan interstellar hitch hiker can carry.

„ ”

Douglas Adams

Page 3: Development with TYPO3 5.0

Inspiring people toshare

The TYPO3 Framework is about the most useful thing a PHP developer can use.

„ ”

Robert Lemke

Brought your own code?

Page 4: Development with TYPO3 5.0

Inspiring people toshare

Topictext

The Guide

One manual for all

available at http://5-0.dev.typo3.org

Inspiring people toshare

Page 5: Development with TYPO3 5.0

Inspiring people toshare

OverviewWhat happened so far ...

System overview

Domain Driven Design

Model View Controller Voodoo

Got Arguments?

Components: playing LEGO™

The aspect of security

Future and other timing issues

Page 6: Development with TYPO3 5.0

Inspiring people toshare

What happened so far

Page 7: Development with TYPO3 5.0

Inspiring people toshare

What happened so far

Buy none get two for free.

CMS5.0

Framework 1.0

Page 8: Development with TYPO3 5.0

Inspiring people toshare

What happened so far

The results so farGeneral design decisions, directory layout, coding guidelines

TYPO3 Framework consisting of:

Component Manager (supports Dependency Injection)

AOP Framework

Package Manager (basic functionality)

MVC Framework (alpha ...)

Property Editor / Validation / Data Types (early dev phase)

Page 9: Development with TYPO3 5.0

Inspiring people toshare

What happened so far

The results even so farerTesting package (contains a PHPUnit testrunner)

TYPO3 CR

dropped Java implementation – started PHP implementation

support JSR-283 instead of JSR-170

Storing and Retrieving nodes works

Page 10: Development with TYPO3 5.0

Inspiring people toshare

What happened so far

The results finallyTypoScript package

improved and enhanced syntax: TypoScript 2.0

fully object oriented and consistent

self-documenting

contains a working TS parser

CMS package

contains a few TS objects and stdWrap ports (processors)

Page 11: Development with TYPO3 5.0

Inspiring people toshare

Read before first use

System Overview

Page 12: Development with TYPO3 5.0

Inspiring people toshare

System Overview

InstallationYou need PHP6

You don't need Java

Current installation options:

svn checkout http://5-0.dev.typo3.org/svn/TYPO3/

download the TYPO3 installer

Page 13: Development with TYPO3 5.0

Inspiring people toshare

System Overview: Installation

Installing PHP6

Page 14: Development with TYPO3 5.0

Inspiring people toshare

System Overview: Installation

Installing TYPO3

Page 15: Development with TYPO3 5.0

Inspiring people toshare

System Overview: Installation

File structure

Inspiring people toshare

Page 16: Development with TYPO3 5.0

Inspiring people toshare

System Overview: Installation

File structure

Inspiring people toshare

Page 17: Development with TYPO3 5.0

Inspiring people toshare

System Overview

ComponentsComponents are re-usable, properly encapsulated objects

The lifecycle of a component and the combination of active components is managed by the Component Manager

All classes in the TYPO3 context are considered as components

Components are configurable

Page 18: Development with TYPO3 5.0

Inspiring people toshare

System Overview: Components

Class ≙ ComponentClasses are automatically registered as components if

they reside in the Classes directory of a package and

their name follows the TYPO3 naming conventions

Page 19: Development with TYPO3 5.0

Inspiring people toshare

System Overview: Components

Example

Page 20: Development with TYPO3 5.0

Inspiring people toshare

System Overview

Package ManagerLike the good old Extension Manager - but without UI yet

Scans the Packages directory for packages

Registers classes as components and partly configures them

Will connect to T3PR (TYPO3 Package Repository)

Package file format is just plain .zip

Will provide access via Web / CLI and offer Web Services

Page 21: Development with TYPO3 5.0

Inspiring people toshare

System Overview

Model View Controlleryes, has it – but what flavor?

index.php contains a tiny bootstrap

the Framework package handles requests, provides a Front Controller and a Dispatcher which dispatches requests to the Action Controllers

more about that later

Page 22: Development with TYPO3 5.0

Inspiring people toshare

System Overview: Model View Controller

index.php

Page 23: Development with TYPO3 5.0

Inspiring people toshare

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

Page 24: Development with TYPO3 5.0

Tower of Babel

Page 25: Development with TYPO3 5.0

Inspiring people toshare

Domain Driven Design

Ubiquitous languageThe common vocabulary is an important prerequisitefor successful collaboration

Use the same words for discussion, modeling, developmentand documentation

Page 26: Development with TYPO3 5.0

Inspiring people toshare

Domain Driven Design

Phone Book Domain Model

Page 27: Development with TYPO3 5.0

Inspiring people toshare

Domain Driven Design

Phone Book Domain Model

Page 28: Development with TYPO3 5.0

Inspiring people toshare

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

Page 29: Development with TYPO3 5.0

Inspiring people toshare

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

Page 30: Development with TYPO3 5.0

Inspiring people toshare

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

Page 31: Development with TYPO3 5.0

Inspiring people toshare

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

Page 32: Development with TYPO3 5.0

Creating a new package

Page 33: Development with TYPO3 5.0

Inspiring people toshare

Domain Driven Design

PhoneBook

DEMO

Page 34: Development with TYPO3 5.0

Inspiring people toshare

Domain Driven Design

PhoneBookEntries

DEMO

Page 35: Development with TYPO3 5.0

Inspiring people toshare

Model View Controller Voodoo

Basic recipeDomain Model

our phone book – contains the data and knows everything about the domain

Action Controller

can handle requests for taking actions - show the phone book entries, create new ones etc.

View

Render the requested output by using the model

Page 36: Development with TYPO3 5.0

Inspiring people toshare

Model View Controller Voodoo

Phone Book Action Controller

DEMO

Page 37: Development with TYPO3 5.0

Inspiring people toshare

Model View Controller Voodoo

Simple Phone Book View

DEMO

Page 38: Development with TYPO3 5.0

Inspiring people toshare

Model View Controller Voodoo

Template View

Page 39: Development with TYPO3 5.0

Inspiring people toshare

Model View Controller Voodoo

Template View

Page 40: Development with TYPO3 5.0

Inspiring people toshare

Model View Controller Voodoo

Template View

DEMO

Page 41: Development with TYPO3 5.0

Inspiring people toshare

Model View Controller Voodoo

Flexible recipeDomain Model

our phone book – contains the data and knows everything about the domain

Action Controller

can handle requests for taking actions - show the phone book entries, create new ones etc.

Views / Widgets

Render the requested output by using the model

Page 42: Development with TYPO3 5.0

Inspiring people toshare

Model View Controller Voodoo

WidgetsIn TYPO3 a Widget is a reusable composite of

a Presentation Model (Model)

a Widget View (View)

a Presentation Controller (Presenter)

Widgets serve as re-usable design elements and as part of the user interface

Page 43: Development with TYPO3 5.0

Inspiring people toshare

Model View Controller Voodoo

WidgetsThe advantages of widgets:

Consistent look and feel for standard presentation elements (tables, lists, forms, texts, images, ...)

Centralized templating, can be overridden for special cases

Automatic support for different request / response types

so easy!

Page 44: Development with TYPO3 5.0

Inspiring people toshare

Model View Controller Voodoo

Presentation ControllerAction Controller Presentation Controller

receives a request, takes the required actions and prepares a response

is configured with a Presentation Model, prepares the presentation and returns

the rendered result

can handle (web- / CLI- / ...) requests can render the widget

handleRequest($request, $response) render()

Page 45: Development with TYPO3 5.0

Inspiring people toshare

Model View Controller Voodoo

Request / ResponseRequest Handler

ResolverWeb Request

Handler Web Request

BuilderWeb Request Dispatcher

Page 46: Development with TYPO3 5.0

Inspiring people toshare

Model View Controller Voodoo

Widget-based Action Controller

Implement the widget based Action Controller

Page 47: Development with TYPO3 5.0

Inspiring people toshare

Model View Controller Voodoo

Widget-based Action Controller

Show that widget also renders at command line

Page 48: Development with TYPO3 5.0

Inspiring people toshare

Got arguments?GET and POST arguments are the No.1 source for XSS and injection attacks

TYPO3 5.0 takes special care of all user input and HTML output

Data Types and Property Editors are used for type conversion at defined stages

Controllers only get access to arguments they registered on beforehand

Page 49: Development with TYPO3 5.0

Inspiring people toshare

Work in progress

We use Property objects instead of string, integer etc. in certain areas

Property objects can be combined (XHTML object + Text object + ....)

"Property editors" are used to transform properties depending on the context

Got arguments?

Properties & Data Types(still hot)

Page 50: Development with TYPO3 5.0

Inspiring people toshare

A concept for validation is in place but not fully implemented yet

We work with "Data Binding"

More details ... this winter.

Got arguments?

Validation

Page 51: Development with TYPO3 5.0

Inspiring people toshare

Got arguments?

Registering arguments

Practical example how to register POST arguments.

Page 52: Development with TYPO3 5.0

Inspiring people toshare

Components

Page 53: Development with TYPO3 5.0

Inspiring people toshare

Components

Playing with building blocksThe combination of components used is configurable(orchestration)

The less components 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 components!

Page 54: Development with TYPO3 5.0

Inspiring people toshare

Components

Component DependenciesComponents seldomly come alone

Components depend on other components which depend on other components which ...

Inspiring people toshare

Page 55: Development with TYPO3 5.0

Inspiring people toshare

Components

Component DependenciesComponents seldomly come alone

Components depend on other components which depend on other components which ...

Problem:

Components explicitly refer to other components:$phoneBookManager = new PhoneBookManager

Inspiring people toshare

Page 56: Development with TYPO3 5.0

Inspiring people toshare

Components

Dependency InjectionA component doesn't ask for the instance of another component but gets it injected

This 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

Page 57: Development with TYPO3 5.0

Inspiring people toshare

Components

Practical examples for DIExample using ...

Constructor Injection

Setter Injection

Autowiring

Page 58: Development with TYPO3 5.0

Inspiring people toshare

Aspect Oriented ProgrammingAOP is a programming paradigm

complements OOP by separating concerns to improve modularization

OOP modularizes concerns: methods, classes, packages

AOP addresses cross-cutting concerns

Page 59: Development with TYPO3 5.0

Inspiring people toshare

Aspect Oriented Programming

Cross-cutting concerns

Presentation

Domain

Data source

Page 60: Development with TYPO3 5.0

Inspiring people toshare

Aspect Oriented Programming

Cross-cutting concerns

Presentation

Domain

Data source

The concerns

live here

Page 61: Development with TYPO3 5.0

Inspiring people toshare

Aspect Oriented Programming

Cross-cutting concerns

Phone BookDomain Model

Security

Logging

Page 62: Development with TYPO3 5.0

Inspiring people toshare

Aspect Oriented Programming

Aspects in action

Practical example

Page 63: Development with TYPO3 5.0

Inspiring people toshare

Beautiful errorsException handling and error handling is (basically) implemented

Special AOP-supported tools for debugging will be available

Verbose debug messages and exception handlers

Page 64: Development with TYPO3 5.0

Inspiring people toshare

Topictext

Page 65: Development with TYPO3 5.0

Inspiring people toshare

Future and other timing issues

Inspiring people toshare

We'll switch from a road map to a country map

Next steps are:

Finish MVC implementation

Properties, Data Types, Validation, Data Binding

Implement Widgets, GUI and an initial Backend package

Continue developing TYPO3 CR

Page 66: Development with TYPO3 5.0

Inspiring people toshare

Future and other timing issues

Inspiring people toshare

Speeeed will be implemented as well

For Patrick Gaumond

Page 67: Development with TYPO3 5.0

Inspiring people toshare

Recommended literature

Page 68: Development with TYPO3 5.0

Inspiring people toshare

Recommended literature

Eric Evans:

Domain Driven DesignTackling Complexity in the Heart of Software

Addison Wesley 2002

Page 69: Development with TYPO3 5.0

Inspiring people toshare

Recommended literature

Martin Fowler:Patterns of Enterprise Application Architecture

Addison Wesley 2002

Page 70: Development with TYPO3 5.0

Inspiring people toshare

Jimmy Nilsson:Applying Domain-DrivenDesign and Patterns

Addison Wesley 2006

Recommended literature

Page 71: Development with TYPO3 5.0

Inspiring people toshare

LinksTYPO3 5.0 Subsitehttp://typo3.org/gimmefive

TYPO3 5.0 Development Websitehttp://5-0.dev.typo3.org

TYPO3 5.0 Documentationhttp://5-0.dev.typo3.org/guide

Jochen Weiland PHP 6 Hostinghttp://www.jweiland.net

Page 72: Development with TYPO3 5.0

Inspiring people toshare

So long and thanks for the fish

Questions

beer

Page 73: Development with TYPO3 5.0