frontastic / common
Requires
- ext-json: *
- ackintosh/ganesha: ^1.2
- algolia/algoliasearch-client-php: ^3.0
- beberlei/assert: ^3.2
- behat/transliterator: ^1.3
- cache/filesystem-adapter: ^1.0
- cloudinary/cloudinary_php: ^1.8
- composer/package-versions-deprecated: @stable
- contentful/contentful: ^6.0|^7.0
- domnikl/statsd: ^2.6
- frontastic/data-object: @stable
- guzzlehttp/guzzle: ^6.3||^7
- guzzlehttp/promises: ^1.0
- justinrainbow/json-schema: @stable
- league/oauth2-client: ^2.3
- myclabs/deep-copy: ^1.0
- ramsey/uuid: ^3.9||^4
- seld/jsonlint: @stable
- swiftmailer/swiftmailer: ^6.2
- symfony/config: ^4.4||^5.4
- symfony/dependency-injection: ^4.4||^5.4
- symfony/event-dispatcher: ^4.4||^5.4
- symfony/expression-language: ^4.4||^5.4
- symfony/finder: ^4.4||^5.4
- symfony/http-kernel: ^4.4||^5.4
- symfony/symfony: ^4.4||^5.4
- symfony/yaml: ^4.4||^5.4
- woohoolabs/yang: ^2.3
Requires (Dev)
- doctrine/common: ^2.9
- frontastic/apidocs: @dev
- pdepend/pdepend: @stable
- phake/phake: ^4.0
- phploc/phploc: @stable
- phpmd/phpmd: @stable
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^8
- sebastian/phpcpd: @stable
- squizlabs/php_codesniffer: @stable
- symfony/swiftmailer-bundle: ^3.4
Suggests
- algolia/algoliasearch-client-php: Marked as suggested to avoid conflicts with users on previous versions
Conflicts
- frontastic/catwalk: <1.68.0
- dev-master
- 2.48.5
- 2.48.4
- 2.48.3
- 2.48.2
- 2.48.1
- 2.48.0
- 2.47.0
- 2.46.0
- 2.45.0
- 2.44.0
- 2.43.0
- 2.42.1
- 2.42.0
- 2.41.1
- 2.41.0
- 2.40.1
- 2.40.0
- 2.39.0
- 2.38.0
- 2.37.0
- 2.36.0
- 2.35.2
- 2.35.1
- 2.35.0
- 2.34.0
- 2.33.9
- 2.33.8
- 2.33.7
- 2.33.6
- 2.33.5
- 2.33.4
- 2.33.3
- 2.33.2
- 2.33.1
- 2.33.0
- 2.32.0
- 2.31.2
- 2.31.1
- 2.31.0
- 2.30.1
- 2.30.0
- 2.29.0
- 2.28.2
- 2.28.1
- 2.28.0
- 2.27.1
- 2.27.0
- 2.26.0
- 2.25.4
- 2.25.3
- 2.25.2
- 2.25.1
- 2.25.0
- 2.24.0
- 2.23.0
- 2.22.0
- 2.21.1
- 2.21.0
- 2.20.1
- 2.20.0
- 2.19.3
- 2.19.2
- 2.19.1
- 2.19.0
- 2.18.2
- 2.18.1
- 2.18.0
- 2.17.2
- 2.17.1
- 2.17.0
- 2.16.2
- 2.16.1
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.4
- 2.13.3
- 2.13.2
- 2.13.1
- 2.13.0
- 2.12.0
- 2.11.10
- 2.11.9
- 2.11.8
- 2.11.7
- 2.11.6
- 2.11.5
- 2.11.4
- 2.11.3
- 2.11.2
- 2.11.1
- 2.11.0
- 2.10.13
- 2.10.12
- 2.10.11
- 2.10.10
- 2.10.9
- 2.10.8
- 2.10.7
- 2.10.6
- 2.10.5
- 2.10.4
- 2.10.3
- 2.10.2
- 2.10.1
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.2
- 2.7.1
- 2.7.0
- 2.6.1
- 2.6.0
- 2.5.1
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.0
- 1.1.20
- 1.1.19
- 1.1.18
- 1.1.17
- 1.1.16
- 1.1.15
- 1.1.14
- 1.1.13
- 1.1.12
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.1
- 1.0.0
- 1.0.0-rc.2
- 1.0.0-beta.9
- 1.0.0-beta.8
- 1.0.0-beta.7
- 1.0.0-beta.6
- 1.0.0-beta.5
- 1.0.0-beta.4
- 1.0.0-beta.3
- 1.0.0-beta.1
- 1.0.0-alpha.8
- 1.0.0-alpha.7
- 1.0.0-alpha.6
- 1.0.0-alpha.5
- 1.0.0-alpha.4
- 1.0.0-alpha.3
- 1.0.0-alpha.2
- dev-dependabot/npm_and_yarn/webpack-5.94.0
- dev-feat/automate-changelog-updates-to-readme
This package is auto-updated.
Last update: 2024-10-30 17:19:27 UTC
README
Copyright (C) Frontastic GmbH - All Rights Reserved
These is a library which contains common domain concepts and functionality for Frontastic.
Documentation about Frontastic can be found at https://docs.frontastic.cloud/ while the API Documentation can be found inside this repository.
API Design Concepts
TL;DR
- Plain data objects without logic
- Logic replaceable encapsulated in services from DIC or factory
- Expose the common base of all back-ends
dangerousInner*
for raw databefore*
/after*
Decorators for customer adjustments
Domain Model
One of the core concepts we believe in in API Design is Injectables vs Newables as described in the Qafoo blog. This is why we have objects modelling the data which usually have no methods at all and objects which implement the service interactions. We call them Data Objects (Newables) and Services (Injectables) in this document.
Data Objects
The Domain Objects model the Data Structures. The only methods which are allowed on Data Objects are methods which nobody would ever implement in a different way. Since the APIs are the base for many different customer projects those methods basically will not exist. A popular example are mail validations in Domain Objects, while the mail validation regular expressions already differ you could even think of using external services to validate the validity of a mail address, which then obviously should not happen in Data Objects.
Our Data Objects are modeled as classes with public properties extending a base DataObject ensuring PHP throws exceptions when accessing non existent properties. We do this to simplify creation and usage – we do not consider getters and setters a must even you could implement additional type checks there. In the near future PHP might even add support for typed properties which would even solve this problem.
While we generally consider immutability of Data Objects a plus, and we should usually not modify them ourselves, our Data Objects are mutable by intention. This enables modification by customers: For examples we allow customers to map out additional properties and allow them to define, for example, additional attributes inside a variant (see Decorators).
For those customers who are allowed to modify PHP code we allow them to extend
the existing Data Objects to create objects with additional properties. So no
class should be final
.
All parameters and return values of methods (except for constructors) should be Data Objects, while we seldomly use scalar values, while this is discouraged. Services must not be parameters (except for the constructor or setter injection) nor return values.
Services
Services implement the actual functionality, like implementing our API interfaces for a certain endpoint. Services are always created by our factories (by configuration) or by the Symfony Dependency Injection Container. Services can also be overwritten by customers, but this should be the last resort to implement a certain functionality. We want to provide sensible extension points (like the decorators) to implement all functionailty.
Beside the general implementation for the API (like ProductApi\Commercetools
)
there may be any number of helper services (like the mapper, the client, …).
Code Structure
There are mainly two types of bundles:
-
API Abstractions
*ApiBundle
(for example theProductApiBundle
)These bundles are supposed to only contain the interfaces and the domain objects. This principle is currently violated by the Commercetools implementation which is part of the API abstractions. This is supposed to be refactored accordingly.
-
API Implementations (for example the
ShopwareBundle
)These bundles implement the API for a certain backend and can be enabled if the customers uses this backend. These API Implementation bundles usually implement the interfaces from the API Abstraction bundles and may contain additional helper services. They should usually not define any Domain Objects.
Besides that there are some additional bundles and infrastructure code like the generic Http-Client-Implementation which allows us to implement, monitor and configure HTTP requests in a generic way.
Decorators
The decorator structure is implemented in
Catwalk but still is relevant to
these APIs: We allow people to hook into every API call using before*
and
after*
decorators for all API methods. This allows people to modify queries
to the API and also the return values of the API. This is the main extension
point for all APIs. On top of this there might be API specific configuration
handled by the API factory.
Dangerous-Inner-*
Many Domain Objects have a dangerousInner*
property (for example
dangerousInnerProduct
) which is a direct reference to the unmodified return
value from the respective API. This allows users of our APIs to access
additional data which our own mappers do not map out to our own Domain Objects.
We understand that we do not cover all potential use cases of the mapped APIs
and this allows people to access the original data inside their decorators. The
dengerousInner*
properties are usually stripped out by the Backend For
Frontend, though, to not leak confidential data and to reduce data size. Also
many API SDKs which might be used by certain implementations use "Domain
Objects" which are not possible to serialize sensibly.