development with typo3 5.0

73
T3CON07 – Karlsruhe, Germany Development with TYPO3 5.0

Upload: robert-lemke

Post on 03-Sep-2014

1.229 views

Category:

Documents


3 download

DESCRIPTION

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.

TRANSCRIPT

T3CON07 – Karlsruhe, Germany

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

Inspiring people toshare

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

„ ”

Robert Lemke

Brought your own code?

Inspiring people toshare

Topictext

The Guide

One manual for all

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

Inspiring people toshare

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

Inspiring people toshare

What happened so far

Inspiring people toshare

What happened so far

Buy none get two for free.

CMS5.0

Framework 1.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)

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

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)

Inspiring people toshare

Read before first use

System Overview

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

Inspiring people toshare

System Overview: Installation

Installing PHP6

Inspiring people toshare

System Overview: Installation

Installing TYPO3

Inspiring people toshare

System Overview: Installation

File structure

Inspiring people toshare

Inspiring people toshare

System Overview: Installation

File structure

Inspiring people toshare

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

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

Inspiring people toshare

System Overview: Components

Example

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

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

Inspiring people toshare

System Overview: Model View Controller

index.php

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

Tower of Babel

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

Inspiring people toshare

Domain Driven Design

Phone Book Domain Model

Inspiring people toshare

Domain Driven Design

Phone Book Domain Model

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

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

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

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

Creating a new package

Inspiring people toshare

Domain Driven Design

PhoneBook

DEMO

Inspiring people toshare

Domain Driven Design

PhoneBookEntries

DEMO

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

Inspiring people toshare

Model View Controller Voodoo

Phone Book Action Controller

DEMO

Inspiring people toshare

Model View Controller Voodoo

Simple Phone Book View

DEMO

Inspiring people toshare

Model View Controller Voodoo

Template View

Inspiring people toshare

Model View Controller Voodoo

Template View

Inspiring people toshare

Model View Controller Voodoo

Template View

DEMO

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

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

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!

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()

Inspiring people toshare

Model View Controller Voodoo

Request / ResponseRequest Handler

ResolverWeb Request

Handler Web Request

BuilderWeb Request Dispatcher

Inspiring people toshare

Model View Controller Voodoo

Widget-based Action Controller

Implement the widget based Action Controller

Inspiring people toshare

Model View Controller Voodoo

Widget-based Action Controller

Show that widget also renders at command line

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

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)

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

Inspiring people toshare

Got arguments?

Registering arguments

Practical example how to register POST arguments.

Inspiring people toshare

Components

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!

Inspiring people toshare

Components

Component DependenciesComponents seldomly come alone

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

Inspiring people toshare

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

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

Inspiring people toshare

Components

Practical examples for DIExample using ...

Constructor Injection

Setter Injection

Autowiring

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

Inspiring people toshare

Aspect Oriented Programming

Cross-cutting concerns

Presentation

Domain

Data source

Inspiring people toshare

Aspect Oriented Programming

Cross-cutting concerns

Presentation

Domain

Data source

The concerns

live here

Inspiring people toshare

Aspect Oriented Programming

Cross-cutting concerns

Phone BookDomain Model

Security

Logging

Inspiring people toshare

Aspect Oriented Programming

Aspects in action

Practical example

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

Inspiring people toshare

Topictext

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

Inspiring people toshare

Future and other timing issues

Inspiring people toshare

Speeeed will be implemented as well

For Patrick Gaumond

Inspiring people toshare

Recommended literature

Inspiring people toshare

Recommended literature

Eric Evans:

Domain Driven DesignTackling Complexity in the Heart of Software

Addison Wesley 2002

Inspiring people toshare

Recommended literature

Martin Fowler:Patterns of Enterprise Application Architecture

Addison Wesley 2002

Inspiring people toshare

Jimmy Nilsson:Applying Domain-DrivenDesign and Patterns

Addison Wesley 2006

Recommended literature

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

Inspiring people toshare

So long and thanks for the fish

Questions

beer