TYPO3 is developing a new framework called TYPO3 5.0 that will provide the foundation for the CMS and other applications. The framework uses components, packages, AOP, MVC and other design patterns to improve modularity, reuse and separation of concerns. It also leverages existing open source frameworks where appropriate. The goal is to develop a flexible yet powerful platform that inspires continued collaboration.
1. Gimme Five!architecture of TYPO3 5.0
The current
The road to TYPO3 5.0 „Phoenix“
TYPO3 Developer Days 25.-29.04.2007, Dietikon / Switzerland
Inspiring people to
share
2. The current architecture?
we don‘t build buildings – design decisions
can be changed most of the time
refactoring is already an important part
of our daily development
with architecture we are referring to
the design decisions we have taken so far
for the core of TYPO3 5.0
Inspiring people to
share
3. The current architecture
„ Software 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
Inspiring people to
share
5. Ubiquitous language
The common vocabulary is an important prerequisite
for successful collaboration
Use the same words for discussion, modeling, development
and documentation
Any vocabulary you know from TYPO3 4.x ?
Inspiring people to
share
6. Ubiquitous language in TYPO3 4.x
Frontend
Page Extension Content
Plugin
Element
Page System
Tree Folder Backend
TypoScript Module dard
Template Object Stan p
Wra
Record TER
File
rks pace Mount
Wo
beer
Inspiring people to
share
7. Ubiquitous language in TYPO3 5.0
Page Package Plugin Content
Element
Page System
Tree Component
Folder
TypoScript dard
Object Stan p
Template Wra
Configura TPR
tion
orks pace Resource
espres
so W
Inspiring people to
share
8. Domain-Driven Design
The domain of our software is content management
We create a model of our domain which is described
by the vocabulary of our ubiquitous language
The PHP code is tightly related to our model which
gives it meaning and makes the model relevant
Inspiring people to
share
9. 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 to
share
10. Layered Architecture
This is the point of
important! our soft ware, the hom
e
This is the real point of our software f the model
o
Domain
Inspiring people to
share
14. Layered Architecture
View
Presentation Controller
Application Logic (Service Layer)
Domain Domain Model (Domain Layer)
Data Mapper
Data source Data Source Abstraction
Inspiring people to
share
16. Infrastructure frameworks
For 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 to
share
18. 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 to
share
19. Innovated, not re-invented
Not 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 to
share
21. C MS ew ork
Fram
5.0 1.0
Inspiring people to
share
22. Focussing on our domain
Framework 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
Inspiring people to
share
27. Components
Components 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 to
share
28. Components: Configuration
The 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 to
share
29. Components: Configuration
Packages/MyPackage/Classes/T3P_MyPackage_MyComponent.php
class T3P_MyPackage_MyComponent {
protected $counter = 0;
public function increaseAndGetCounter() {
return $this->counter ++;
}
}
Inspiring people to
share
30. Components: Configuration
Packages/MyPackage/Classes/T3P_MyPackage_MyComponent.php
Packages/MyPackage/Classes/Components.conf
class T3P_MyPackage_MyComponent {
[T3P_MyPackage_MyComponent]
scope = prototype = 0;
protected $counter
public function increaseAndGetCounter() {
return $this->counter ++;
}
}
Inspiring people to
share
31. 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 to
share
32. 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 to
share
33. 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 to
share
34. 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 to
share
35. Components:
Dependency Injection
Different ways of injection:
Constructor injection
Setter injection
Dependencies are resolved automatically
Classes are loaded automatically
... of course: configurable
Inspiring people to
share
36. Packages
Extensions 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 to
share
37. Packages: Package Manager
Manages 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 to
share
38. Aspect Oriented Programming
AOP 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 to
share
45. AOP: Method interception
Hypothetical
code example
class T3P_User_AccountManagement {
public function deleteAccount($accountId) {
$this->accountRepository->delete($accountId);
}
}
Inspiring people to
share
46. AOP: Method interception
class T3P_Security_RightsManager {
public function hasEnoughRights($situation) {
$account = $this->accountManager->getCurrentAccount();
return $account->hasEnoughRightsForSituation($situation);
}
}
Inspiring people to
share
47. AOP: Method interception
class 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 to
share
48. AOP: Implementation details
TYPO3 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 to
share
49. AOP
Where it makes sense:
Cross-cutting concerns
Extending legacy code
Caveats:
Scattered code, multiple extensions
check out clean OOP alternatives
Inspiring people to
share
50. Model, View, Controller
MVC 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 to
share
52. Resources
Resource 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 to
share
53. Reflection
Extended 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 to
share
54. Utility
Home of t3lib_div-like tools
Some functions have already been ported
Inspiring people to
share
55. TYPO3 CMS
Currently working on the model / node types
TypoScript 2.0
Content Repository
Inspiring people to
share
56. Some project ideas
Implement 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 to
share
57. Recommended literature
Gamma et al.:
Design Patterns
Elements of Reusable Object-
Oriented Software
Addison Wesley 1995
Inspiring people to
share
58. Recommended literature
Martin Fowler:
Refactoring
Improving the Design of Existing
Code
Addison Wesley 1999
Inspiring people to
share
59. Recommended literature
Kent Beck:
Test-Driven Development
By Example
Addison Wesley 2002
Inspiring people to
share
60. Recommended literature
Martin Fowler:
Patterns of Enterprise
Application Architecture
Addison Wesley 2002
Inspiring people to
share
61. Recommended literature
Eric Evans:
Domain Driven Design
Tackling Complexity in the Heart of
Software
Addison Wesley 2002
Inspiring people to
share