1 of 23

TYPO3 & the benefits of a �a resource-oriented architecture

Thomas Maroschik

CTO & shareholder at DFAU GmbH,�the creators of toujou,�the TYPO3 website builder.��@tmaroschik

2 of 23

Imagine sitting in a train. Replying to comments of a tweet, changing the poster image of a YouTube video, being alerted about a product running out of stock and granting your colleague permission to use iStockphoto images in his blog post.

All from within TYPO3.

3 of 23

4 of 23

“…the World Wide Web is designed to be constrained by the REST [resource-oriented] series of limitations…“ ¹

“…central feature that distinguishes the REST architectural style from other network-based styles is its emphasis on a uniform interface…“ ²

By applying the same design to TYPO3,�users can consume and produce web resources through a unified interface.

What is the web?

5 of 23

When the whole world speaks a certain language�and I want to communicate efficiently,�I would be better off as a native speaker.

TYPO3 should SPEAK, LISTEN and THINK like the web, to become an interconnected content hub.

Why should we care?

6 of 23

“…concept of a web resource has evolved during the Web's history, from the early notion of static addressable documents or files, to a more generic and abstract definition, now encompassing every "thing" or entity…“ ¹

¹ https://en.wikipedia.org/wiki/Web_resource

By applying the same design to TYPO3,�users can consume and produce web resources through a unified interface.

Did something change? Isn’t the web document-oriented?

7 of 23

By using the same concepts

  • Text hier einfügen
  • Text hier einfügen

Resources

  • how to distinguish concepts
  • how to describe concepts

Verbs

  • how to interact with resources
  • how to manipulate resources

Links

  • how to connect resources
  • how to discover resources

How can TYPO3 start to think like the web?

8 of 23

By applying the same constraints ¹

How can TYPO3 start to speak and listen like the web?

  • Client-Server�➔ separation of concerns, components evolve independently
  • Stateless�➔ requests/responses contain all data necessary to understand a message
  • Cache�➔ clients need to know if responses are cacheable and how they invalidate
  • Layered System�➔ each component cannot see beyond the immediate layer they are interacting with
  • Uniform Interface�➔ standardized way of communication

¹ https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm#sec_5_1

9 of 23

A resource is every information�that can be named ¹

  • Page
  • Content Element
  • Image
  • Site Configuration
  • Backend Layout
  • Tweet
  • Youtube Comment
  • Hubspot Contact
  • Analytics Report
  • Mautic Campaign
  • Form
  • Remote operation
  • Webhook
  • Permissions
  • Metadata

What can be a resource in TYPO3?

¹ https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm#sec_5_2_1_1

10 of 23

A resource has common properties

Type/Kind ¹

All resources of the same kind share the same characteristics.

  • Page
  • Tweet
  • Webhook

Name/Identifier ¹

Distinguishes resources of the same kind within a namespace.

  • number: 1337
  • uuid: e48b3d30-b779-…
  • name: form-final-v4

Namespace (optional)

A scope in which identifiers of resources of the same kind are unique.

  • Page
  • Site
  • Youtube Channel

What makes something a TYPO3 resource?

¹ https://jsonapi.org/format/#document-resource-object-identification

11 of 23

A resource provides interactions�through verbs

How could we interact with TYPO3 resources?

  • create
  • get/list
  • update
  • patch
  • delete
  • move
  • translate
  • publish
  • archive

All verbs are individual per resource. Authors are advised to support the basic CRUD verbs.

12 of 23

A resource can be a subresource

  • owned by a parent resource
  • can be nested
  • collection or item
  • has individual verbs
  • allows for fine grained authorization

What if a TYPO3 resource is not enough?

  • e.g. comments
  • translations
  • versions
  • status
  • operations

13 of 23

Applying the same patterns fractally

How could we apply the constraints throughout the systems?

Constraint

internally

externally

Client - Server

e.g. Controller/Service - Repository

e.g. Browser/Service - API Endpoint

Stateless

changes to resources are single transactions�e.g. $repo->update($object)

changes to resources are single transactions�e.g. PUT /api/page/1234

Cache

resources expose versions/changes or lifetimes if cacheable�e.g. by implementing different interfaces

resources expose versions/changes or lifetimes if cacheable�e.g. HTTP Cache/ETag Headers

Layered System

require client - server role model between every layer through�hexagonal architecture that forms a self repeating pattern of the components

14 of 23

The uniform interface is�a standardized way of communication ¹

What’s the uniform interface to resources?

¹ https://restapilinks.com/uniform-interface/

  • how to identify
  • how to manipulate
  • how to discover
  • how to learn about characteristics

15 of 23

A resource or collection is identified by URIs ¹

How could we identify resources in TYPO3?

¹ https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#URLs_and_URNs

URI�Uniform Resource Identifier

URN�Uniform Resource�Name

URL�Uniform Resource�Locator

identifies a resource by name in a particular namespace

e.g. urn:t3:page:1234

identifies a resource by its location

e.g. http://example.org/foo/

internally

externally

16 of 23

A resource may have many representations.

  • Instances Of Classes implementing the Resource Interface
  • Arrays/Anonymous Objects
  • URIs

How could we manipulate resources in TYPO3?

  • HTML
  • JSON/YAML
  • RDF/JSON-LD
  • XML

internally (PHP)

externally (HTTP/gRPC/…)

Manipulation happens by interacting with the representations�via the resource provided verbs. (e.g. HTTP Methods/Class Methods/Commands)

17 of 23

A resource registry acts as a catalog

  • Single Registry Class Instance
  • Lists Available Resources With Metadata/Schema Resources
  • Code And Data Defined Resources

How could we find out about available resources and their characteristics in TYPO3?

  • Single API Endpoint
  • Lists Available Resources With Metadata/Schema Resources
  • OpenAPI v3 and OPTIONS Request

internally (PHP)

externally (HTTP/gRPC/…)

As interfaces are externally described via OpenAPI v3, a subset of JSON Schema,�all resources are constrained to the limitations of JSON Schema.

18 of 23

A resource link is a reference to a resource or collection that the client can follow ¹

  • Instance Of Resource Reference
  • URL or URN via Resource Registry

What role could links between TYPO3 resources play?

  • URL

internally (PHP)

externally (HTTP/gRPC/…)

¹ https://en.wikipedia.org/wiki/Hyperlink

It is not guaranteed that a link can actually be successfully followed.�The target resource might be temporarily or permanently unavailable.

19 of 23

Intermission

20 of 23

Establishing the uniform interface �internally first

How do we start implement this in TYPO3?

  • find first principles that guide the implementation (e.g. why are we doing this/that?)
  • derive inspiration from other successful implementations (e.g. Spring Data, Kubernetes)
  • find overlaps with good programming practices (e.g. DDD, hexagonal architecture, CQRS)
  • develop contracts that enforce the principles (e.g. Class Interfaces, Patterns)
  • be super defensive about what we allow in the first iterations (e.g. final/private first)
  • challenge all assumptions with prototypical implementations

21 of 23

Create building blocks that aid�in building domain specific applications

What’s next?

  • resource storage adapters (e.g. Doctrine ORM, Solr, Mongodb, Twitter API)
  • resource permissions (e.g. RBAC, ABAC, UMA, internally/externally stored, Keycloak)
  • resource editors (e.g. Lists, Forms, Data Grids, Image Editors)
  • resource events (e.g. Replication, Domain Events, Webhooks)
  • resource models (e.g. Documents, Hierarchies, Streaming, Event Sourcing)
  • resource mappers (e.g. API Platform)

22 of 23

What do you think?

Thank you for your attention.

23 of 23

Discussion