the current architecture of typo3 5.0
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
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
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
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
„
”
Tower of Babel
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 ?
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
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
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
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());}
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!
Inspiring people toshare
Layered Architecture
Domain
Data source
Inspiring people toshare
Layered Architecture
Presentation
Domain
Data source
Inspiring people toshare
Layered Architecture
Presentation
Domain
Data source
Inspiring people toshare
Layered Architecture
Presentation
Domain
Data source
Application Logic (Service Layer)
Domain Model (Domain Layer)
View
Controller
Data Mapper
Data Source Abstraction
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
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
Inspiring people toshare
Why re-invent the wheel?
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
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
Inspiring people toshare
Inspiring people toshare
CMS
5.0 Framewor
k
1.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
TYPO3 Framework
Inspiring people toshare
TYPO3 FrameworkComponents
Packages
Aspect Oriented Programming
Model, View, Controller
Resources
Reflection
Utility
Inspiring people toshare
TYPO3 Framework
Inspiring people toshare
TYPO3 Framework
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
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
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
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
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
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‘);
}}
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‘);
}}
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‘);
}}
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
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
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
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
AOP: Cross-cutting concerns
Presentation
Domain
Data source
Inspiring people toshare
AOP: Cross-cutting concerns
Presentation
Domain
Data source
The concerns
live here
Inspiring people toshare
ContentForum News PartiesGuestbook
AOP: Cross-cutting concerns
Domain
Inspiring people toshare
Forum News Content PartiesGuestbook
AOP: Cross-cutting concerns
Security
Logging
Inspiring people toshare
LoggingSecurity Forum News Content PartiesGuestbook
AOP: Cross-cutting concerns
Inspiring people toshare
Forum News Content PartiesGuestbook
AOP: Cross-cutting concerns
SecurityLogging
Inspiring people toshare
AOP: Method interception
class T3P_User_AccountManagement {public function deleteAccount($accountId) {
$this->accountRepository->delete($accountId);}
}
Hypothetical
code example
Inspiring people toshare
AOP: Method interception
class T3P_Security_RightsManager {public function hasEnoughRights($situation) {
$account = $this->accountManager->getCurrentAccount();return $account->hasEnoughRightsForSituation($situation);
}}
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’);}
}}
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
Inspiring people toshare
AOPWhere it makes sense:
Cross-cutting concerns
Extending legacy code
Caveats:
Scattered code, multiple extensions
check out clean OOP alternatives
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 ...
Inspiring people toshare
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
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
Inspiring people toshare
UtilityHome of t3lib_div-like tools
Some functions have already been ported
Inspiring people toshare
TYPO3 CMSCurrently working on the model / node types
TypoScript 2.0
Content Repository
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
Inspiring people toshare
Recommended literature
Gamma et al.:Design PatternsElements of Reusable Object-Oriented Software
Addison Wesley 1995
Inspiring people toshare
Recommended literature
Martin Fowler:RefactoringImproving the Design of Existing Code
Addison Wesley 1999
Inspiring people toshare
Recommended literature
Kent Beck:Test-Driven DevelopmentBy Example
Addison Wesley 2002
Inspiring people toshare
Recommended literature
Martin Fowler:Patterns of Enterprise Application Architecture
Addison Wesley 2002
Inspiring people toshare
Recommended literature
Eric Evans:
Domain Driven DesignTackling Complexity in the Heart of Software
Addison Wesley 2002
Inspiring people toshare
Recommended literature
Inspiring people toshare
Thanks for listeningRobert Lemke <[email protected]>
Gimme Five!The road to TYPO3 5.0 „Phoenix“