the current architecture of typo3 5.0

64
Gimme Five! The road to TYPO3 5.0 „Phoenix“ The current architecture of TYPO3 5.0 TYPO3 Developer Days 25.-29.04.2007, Dietikon / Switzerland Inspiring people to share

Upload: robert-lemke

Post on 08-May-2015

9.508 views

Category:

Documents


0 download

DESCRIPTION

These are the slides of the presentation of the current TYPO3 5.0 architecture from the TYPO3 Developer Days in Dietikon, Switzerland in 2007. Please refer to the 5.0 documentation for a more detailed explanation of the features and some code examples.

TRANSCRIPT

Page 1: The current architecture of TYPO3 5.0

Gimme Five!The road to TYPO3 5.0 „Phoenix“

The current architecture of TYPO3 5.0 TYPO3 Developer Days 25.-29.04.2007, Dietikon / Switzerland

Inspiring people toshare

Page 2: The current architecture of TYPO3 5.0

Inspiring people toshare

The current architecture?we don‘t build buildings – design decisionscan be changed most of the time

refactoring is already an important partof our daily development

with architecture we are referring tothe design decisions we have taken so farfor the core of TYPO3 5.0

Page 3: The current architecture of TYPO3 5.0

Inspiring people toshare

The current architectureSoftware is not limited by physics,like buildings are. It is limited by imagination, by design, by organization. In short, it is limited by properties of people,not by properties of the world.

Martin Fowler

Page 4: The current architecture of TYPO3 5.0

Tower of Babel

Page 5: The current architecture of TYPO3 5.0

Inspiring people toshare

Ubiquitous languageThe common vocabulary is an important prerequisitefor successful collaboration

Use the same words for discussion, modeling, developmentand documentation

Any vocabulary you know from TYPO3 4.x ?

Page 6: The current architecture of TYPO3 5.0

Inspiring people toshare

Ubiquitous language in TYPO3 4.x

Page Content Element

Page Tree

ExtensionFrontend Plugin

Backend Module

System Folder

Standard

WrapTemplate Record

TypoScript Object

File MountWorkspace

beer

TER

Page 7: The current architecture of TYPO3 5.0

Inspiring people toshare

Ubiquitous language in TYPO3 5.0

Page Content Element

Page Tree

PackagePlugin

ComponentSystem Folder

Standard

WrapTemplate Configuration

TypoScript Object

ResourceWorkspace

espresso

TPR

Page 8: The current architecture of TYPO3 5.0

Inspiring people toshare

Domain-Driven DesignThe domain of our software is content management

We create a model of our domain which is describedby the vocabulary of our ubiquitous language

The PHP code is tightly related to our model whichgives it meaning and makes the model relevant

Page 9: The current architecture of TYPO3 5.0

Inspiring people toshare

Domain-Driven Design„Set the Modification Date of each Content Element of the Page with the Unique Identifier 1 to the current time“

$page = $pageRepository->findByUid(1);foreach ($page->getContentElements() as $contentElement) { $contentElement->setModificationDate(time());}

Page 10: The current architecture of TYPO3 5.0

Inspiring people toshare

Layered Architecture

Domain

This is the real point of our software

This is the point of

our software, the home

of the modelimportant!

Page 11: The current architecture of TYPO3 5.0

Inspiring people toshare

Layered Architecture

Domain

Data source

Page 12: The current architecture of TYPO3 5.0

Inspiring people toshare

Layered Architecture

Presentation

Domain

Data source

Page 13: The current architecture of TYPO3 5.0

Inspiring people toshare

Layered Architecture

Presentation

Domain

Data source

Page 14: The current architecture of TYPO3 5.0

Inspiring people toshare

Layered Architecture

Presentation

Domain

Data source

Application Logic (Service Layer)

Domain Model (Domain Layer)

View

Controller

Data Mapper

Data Source Abstraction

Page 15: The current architecture of TYPO3 5.0

Inspiring people toshare

Infrastructure

PHP

ObjectManagement

Data Source Abstraction

MVC Framework

Object Relational Mapping

Error Handling

Logging VersioningPackage

ManagementResource

Management

Profiling

Caching

MessagingTransaction

Management

Debugging

Page 16: The current architecture of TYPO3 5.0

Inspiring people toshare

Infrastructure frameworksFor the infrastructure of TYPO3 we need a lot of features, which are probably covered by existing frameworks we can use:

Object Mgm. / Dependecy Injection: Seasar, Pico Container

Model, View, Controller: Agavi

Aspect Oriented Programming: Seasar, GAP, aspectPHP, ...

Database / -model Abstraction: Propel, Creole

... and many more

Page 17: The current architecture of TYPO3 5.0

Inspiring people toshare

Why re-invent the wheel?

Page 18: The current architecture of TYPO3 5.0

Inspiring people toshare

Re-invent the wheel because ...some of the frameworks follow a weird, unclean or inconsistent approach

some of the frameworks are not mature enough or badly documented / coded.

some of the frameworks don‘t offer all the features we want

some projects don‘t have a stable community and support

we want a whole, component-based, feature-rich framework offering a consistent interface to the developer which increases quality, speed and ease of development

Page 19: The current architecture of TYPO3 5.0

Inspiring people toshare

Innovated, not re-inventedNot just a re-invention, we ...

... looked at the best wheels which exist today(other programming languages have nice wheels, too)

... studied the history of wheels and what experience others made while using them

... added our own creativity and expertise

Recipe: Take the best wheels, attach them to a lean, yet powerful vessel (framework) and add the TYPO3 flavour

Page 20: The current architecture of TYPO3 5.0

Inspiring people toshare

Page 21: The current architecture of TYPO3 5.0

Inspiring people toshare

CMS

5.0 Framewor

k

1.0

Page 22: The current architecture of TYPO3 5.0

Inspiring people toshare

Focussing on our domainFramework and CMS: exist as independent packages

Enforces clean separation of infrastructure and business logic

The Framework can be used without the TYPO3 CMS and serve as a foundation for any enterprise PHP application

Packages contain additional functionality for CMS- and other applications

The TYPO3 Package Repository can be used independently from the TYPO3 CMS

Page 23: The current architecture of TYPO3 5.0

TYPO3 Framework

Page 24: The current architecture of TYPO3 5.0

Inspiring people toshare

TYPO3 FrameworkComponents

Packages

Aspect Oriented Programming

Model, View, Controller

Resources

Reflection

Utility

Page 25: The current architecture of TYPO3 5.0

Inspiring people toshare

TYPO3 Framework

Page 26: The current architecture of TYPO3 5.0

Inspiring people toshare

TYPO3 Framework

Page 27: The current architecture of TYPO3 5.0

Inspiring people toshare

ComponentsComponents are re-usable, properly encapsulated objects which are managed by the Component Manager

(Almost) all classes in the TYPO3 context are components

Components are configurable

They allow for Dependency Injection

Page 28: The current architecture of TYPO3 5.0

Inspiring people toshare

Components: ConfigurationThe Component Manager controls the life cycle of a component

The scope of a component is just a matter of configuration:

prototype, singleton or session

A component is referred to by its name, the implementation class is configurable:

comparable to the XCLASS mechanism in TYPO3 4.x

implementations sharing the same interface act as true drop-in replacements

Page 29: The current architecture of TYPO3 5.0

Inspiring people toshare

Components: Configuration

class T3P_MyPackage_MyComponent {

protected $counter = 0;

public function increaseAndGetCounter() {return $this->counter ++;

}}

Packages/MyPackage/Classes/T3P_MyPackage_MyComponent.php

Page 30: The current architecture of TYPO3 5.0

Inspiring people toshare

Components: Configuration

class T3P_MyPackage_MyComponent {

protected $counter = 0;

public function increaseAndGetCounter() {return $this->counter ++;

}}

Packages/MyPackage/Classes/T3P_MyPackage_MyComponent.php

[T3P_MyPackage_MyComponent]scope = prototype

Packages/MyPackage/Classes/Components.conf

Page 31: The current architecture of TYPO3 5.0

Inspiring people toshare

Components: Dependency Injection

Inverse of Control or Hollywood Principle: „Don‘t call us, we call you“

Your component needs access to a Logger

Usual case: Your code asks the framework to deliver a logger instance

With Dependency Injection:Your code just gets an instance of the logger injected

Page 32: The current architecture of TYPO3 5.0

Inspiring people toshare

Components: Dependency Injection

class tx_myextension_pi1 {

protected $logger;

public function __construct() {$this->logger = t3lib_div::makeInstance(’tx_log_logger‘);

}

public function main() {$this->logger->log(’Hello log file‘);

}}

Page 33: The current architecture of TYPO3 5.0

Inspiring people toshare

Components: Dependency Injection

class tx_myextension_pi1 {

protected $logger;

public function __construct() {$this->logger = tx_log_logger::getInstance(); # Custom Singleton implementation

}

public function main() {$this->logger->log(’Hello log file‘);

}}

Page 34: The current architecture of TYPO3 5.0

Inspiring people toshare

Components: Dependency Injection

class T3P_MyPackage_MyComponent {

protected $logger;

public function __construct(T3P_Log_LoggerInterface $logger) {$this->logger = $logger;

}

public function main() {$this->logger->log(’Hello log‘);

}}

Page 35: The current architecture of TYPO3 5.0

Inspiring people toshare

Components: Dependency Injection

Different ways of injection:

Constructor injection

Setter injection

Dependencies are resolved automatically

Classes are loaded automatically

... of course: configurable

Page 36: The current architecture of TYPO3 5.0

Inspiring people toshare

PackagesExtensions are now called Packages

A package is any combination of meta data, code, documentation, media and other resources

Packages can be up- and downloaded from the Package Repository

Documentation is stored as DocBook

The exchange format for packages is a plain ZIP file

Page 37: The current architecture of TYPO3 5.0

Inspiring people toshare

Packages: Package ManagerManages packages - replacement for the Extension Manager

Accessible through command line and SOAP

The package manager can even upgrade the Framework package, ie. it can upgrade itself

Page 38: The current architecture of 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 39: The current architecture of TYPO3 5.0

Inspiring people toshare

AOP: Cross-cutting concerns

Presentation

Domain

Data source

Page 40: The current architecture of TYPO3 5.0

Inspiring people toshare

AOP: Cross-cutting concerns

Presentation

Domain

Data source

The concerns

live here

Page 41: The current architecture of TYPO3 5.0

Inspiring people toshare

ContentForum News PartiesGuestbook

AOP: Cross-cutting concerns

Domain

Page 42: The current architecture of TYPO3 5.0

Inspiring people toshare

Forum News Content PartiesGuestbook

AOP: Cross-cutting concerns

Security

Logging

Page 43: The current architecture of TYPO3 5.0

Inspiring people toshare

LoggingSecurity Forum News Content PartiesGuestbook

AOP: Cross-cutting concerns

Page 44: The current architecture of TYPO3 5.0

Inspiring people toshare

Forum News Content PartiesGuestbook

AOP: Cross-cutting concerns

SecurityLogging

Page 45: The current architecture of TYPO3 5.0

Inspiring people toshare

AOP: Method interception

class T3P_User_AccountManagement {public function deleteAccount($accountId) {

$this->accountRepository->delete($accountId);}

}

Hypothetical

code example

Page 46: The current architecture of TYPO3 5.0

Inspiring people toshare

AOP: Method interception

class T3P_Security_RightsManager {public function hasEnoughRights($situation) {

$account = $this->accountManager->getCurrentAccount();return $account->hasEnoughRightsForSituation($situation);

}}

Page 47: The current architecture of TYPO3 5.0

Inspiring people toshare

AOP: Method interceptionclass T3P_User_AccountManagement {

public function deleteAccount($accountId) {$account = $this->accountManager->getCurrentAccount();if ($account->hasEnoughRightsForSituation($situation)) {

$this->accountRepository->delete($accountId);} else {

throw new NotEnoughtRightsException(’Access denied’);}

}}

Page 48: The current architecture of TYPO3 5.0

Inspiring people toshare

AOP: Implementation detailsTYPO3 makes use of dynamic proxies for weaving

Our AOP Framework does not require any pre-processing or a special PHP extension to run

Standards are used where they made sense, other parts are simplified or adapted to the PHP capabilities

only low performance loss because weaving is a one-time operation which can be cached

Page 49: The current architecture of TYPO3 5.0

Inspiring people toshare

AOPWhere it makes sense:

Cross-cutting concerns

Extending legacy code

Caveats:

Scattered code, multiple extensions

check out clean OOP alternatives

Page 50: The current architecture of TYPO3 5.0

Inspiring people toshare

Model, View, ControllerMVC Framework is work in progress

Some design decisions taken:

Request Handler with filter chain

Dispatcher with interceptor chain

One controller per plugin, multiple actions per controller

Code is on the way ...

Page 51: The current architecture of TYPO3 5.0

Inspiring people toshare

Page 52: The current architecture of TYPO3 5.0

Inspiring people toshare

ResourcesResource Manager for centralizing resource access

Media, documents, generic files and other resources are available as resource objects

File resources from the packages are detected and managed automatically

Allows for fine-grained rights management and performance optimization

Status: Pending

Page 53: The current architecture of TYPO3 5.0

Inspiring people toshare

ReflectionExtended reflection capabilities

Allow for accessing tags in doc comments directly

Will feature some caching mechanism in the future

Maybe an annotation manager will be added

Page 54: The current architecture of TYPO3 5.0

Inspiring people toshare

UtilityHome of t3lib_div-like tools

Some functions have already been ported

Page 55: The current architecture of TYPO3 5.0

Inspiring people toshare

TYPO3 CMSCurrently working on the model / node types

TypoScript 2.0

Content Repository

Page 56: The current architecture of TYPO3 5.0

Inspiring people toshare

Some project ideasImplement the TYPO3 Package Repository as 5.0 package

Create a 5.0 implementation of the Party Information Framework

Integrate 5.0 as a 4.x frontend plugin

Create a bootstrap-like, everything-works-auto-installer

Page 57: The current architecture of TYPO3 5.0

Inspiring people toshare

Recommended literature

Gamma et al.:Design PatternsElements of Reusable Object-Oriented Software

Addison Wesley 1995

Page 58: The current architecture of TYPO3 5.0

Inspiring people toshare

Recommended literature

Martin Fowler:RefactoringImproving the Design of Existing Code

Addison Wesley 1999

Page 59: The current architecture of TYPO3 5.0

Inspiring people toshare

Recommended literature

Kent Beck:Test-Driven DevelopmentBy Example

Addison Wesley 2002

Page 60: The current architecture of TYPO3 5.0

Inspiring people toshare

Recommended literature

Martin Fowler:Patterns of Enterprise Application Architecture

Addison Wesley 2002

Page 61: The current architecture of TYPO3 5.0

Inspiring people toshare

Recommended literature

Eric Evans:

Domain Driven DesignTackling Complexity in the Heart of Software

Addison Wesley 2002

Page 62: The current architecture of TYPO3 5.0

Inspiring people toshare

Recommended literature

Page 63: The current architecture of TYPO3 5.0

Inspiring people toshare

Thanks for listeningRobert Lemke <[email protected]>

Page 64: The current architecture of TYPO3 5.0

Gimme Five!The road to TYPO3 5.0 „Phoenix“