Skip to content

Commit 2aa6ff4

Browse files
committed
Adds comprehensive documentation on customizing, integrating, and using the Fast Forward Framework, including new files and sections on HTTP services, compatibility, FAQs, and use cases. Updates the index and link references for improved navigation.
Signed-off-by: Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
1 parent 66d2baf commit 2aa6ff4

19 files changed

+877
-70
lines changed

docs/advanced/customization.rst

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
Customization
2+
=============
3+
4+
The framework package is intentionally small, so customization mostly happens by composing extra
5+
providers around ``FrameworkServiceProvider``.
6+
7+
Add your own provider
8+
---------------------
9+
10+
Register your application provider after the framework provider:
11+
12+
.. code-block:: php
13+
14+
use App\ServiceProvider\AppServiceProvider;
15+
use FastForward\Framework\ServiceProvider\FrameworkServiceProvider;
16+
use function FastForward\Container\container;
17+
18+
$container = container(
19+
new FrameworkServiceProvider(),
20+
new AppServiceProvider(),
21+
);
22+
23+
This keeps the framework defaults while giving your application room to add domain-specific
24+
services.
25+
26+
Override an existing service identifier
27+
---------------------------------------
28+
29+
``AggregateServiceProvider`` merges factory arrays in provider order. In practice, that means a
30+
later provider can replace an earlier factory when both use the same service identifier.
31+
32+
This is the simplest override strategy when you want to swap a default implementation entirely.
33+
34+
Decorate an existing service with extensions
35+
--------------------------------------------
36+
37+
If you want to wrap an existing service instead of replacing it, use provider extensions:
38+
39+
.. code-block:: php
40+
41+
use Interop\Container\ServiceProviderInterface;
42+
use Psr\Container\ContainerInterface;
43+
use Psr\Http\Client\ClientInterface;
44+
45+
final class DecoratorServiceProvider implements ServiceProviderInterface
46+
{
47+
public function getFactories(): array
48+
{
49+
return [];
50+
}
51+
52+
public function getExtensions(): array
53+
{
54+
return [
55+
ClientInterface::class => static function (
56+
ContainerInterface $container,
57+
ClientInterface $client,
58+
): ClientInterface {
59+
return new LoggingClient($client);
60+
},
61+
];
62+
}
63+
}
64+
65+
The aggregate provider composes extensions in order, so later decorators wrap earlier ones.
66+
Replace ``LoggingClient`` with your own decorator implementation.
67+
68+
Documented limitations
69+
----------------------
70+
71+
- This package does not define framework-specific aliases or facades of its own.
72+
- The convenience aliases and helper factories live in the downstream HTTP factory package.
73+
- If you need additional providers for config-driven applications, register them explicitly or
74+
list them in ``FastForward\Container\ContainerInterface::class`` inside your config object.
75+
76+
Good customization defaults for new projects
77+
--------------------------------------------
78+
79+
1. Start with ``FrameworkServiceProvider`` only.
80+
2. Add one application provider for your own services.
81+
3. Reach for overrides only after you know which service identifier you need to replace.
82+
4. Use extensions when you want to decorate behavior instead of rewriting the original factory.

docs/advanced/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
Advanced
22
========
33

4-
Advanced topics for extending and integrating the Fast Forward Framework.
4+
Advanced topics for composing the framework with your own providers, integrating it into different
5+
runtime styles, and understanding how service overrides behave.
56

67
.. toctree::
78
:maxdepth: 1
89

910
integration
11+
customization

docs/advanced/integration.rst

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,81 @@
11
Integration
22
===========
33

4-
The Fast Forward Framework is designed to integrate seamlessly with other PSR-compliant packages and libraries. You can add or override service providers as needed to customize your application's infrastructure.
4+
Fast Forward Framework is intentionally small and integrates best when you treat it as a bootstrap
5+
layer for the rest of your application.
6+
7+
Integrate with the Fast Forward container
8+
----------------------------------------
9+
10+
The recommended integration path is the ``container()`` helper from ``fast-forward/container``.
11+
12+
.. code-block:: php
13+
14+
use FastForward\Framework\ServiceProvider\FrameworkServiceProvider;
15+
use function FastForward\Container\container;
16+
17+
$container = container(new FrameworkServiceProvider());
18+
19+
Integrate through configuration
20+
-------------------------------
21+
22+
When you want your provider list to live in configuration, you can pass a config object into the
23+
container helper:
24+
25+
.. code-block:: php
26+
27+
use App\ServiceProvider\AppServiceProvider;
28+
use FastForward\Config\ArrayConfig;
29+
use FastForward\Container\ContainerInterface;
30+
use FastForward\Framework\ServiceProvider\FrameworkServiceProvider;
31+
use function FastForward\Container\container;
32+
33+
$config = new ArrayConfig([
34+
ContainerInterface::class => [
35+
FrameworkServiceProvider::class,
36+
AppServiceProvider::class,
37+
],
38+
]);
39+
40+
$container = container($config);
41+
42+
This keeps environment-specific providers in one place and works well with the rest of the
43+
configuration package.
44+
45+
HTTP runtime versus CLI runtime
46+
-------------------------------
47+
48+
The framework provider registers ``Psr\Http\Message\ServerRequestInterface`` by calling
49+
``fromGlobals()`` through the downstream HTTP factory provider. That is convenient in web
50+
contexts, but it also means you should be deliberate in CLI commands and automated tests.
51+
52+
For CLI or tests, prefer explicit request creation:
53+
54+
.. code-block:: php
55+
56+
use Psr\Http\Message\RequestFactoryInterface;
57+
58+
$requestFactory = $container->get(RequestFactoryInterface::class);
59+
$request = $requestFactory->createRequest('GET', 'https://example.test/health');
60+
61+
PSR-oriented application services
62+
---------------------------------
63+
64+
Because the container exposes PSR interfaces, your application code can type-hint the standard
65+
contracts instead of framework-specific implementations:
66+
67+
.. code-block:: php
68+
69+
use Psr\Http\Client\ClientInterface;
70+
use Psr\Http\Message\ResponseFactoryInterface;
71+
72+
final readonly class StatusPageAction
73+
{
74+
public function __construct(
75+
private ClientInterface $client,
76+
private ResponseFactoryInterface $responseFactory,
77+
) {}
78+
}
79+
80+
This keeps your domain services portable even when you rely on the Fast Forward ecosystem for
81+
bootstrap and defaults.

docs/api/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
API Reference
22
============
33

4-
This section documents the main classes and interfaces provided by the Fast Forward Framework.
4+
This section documents the local framework service provider and the most important classes and
5+
functions you will touch immediately after installing the metapackage.
56

67
.. toctree::
78
:maxdepth: 1
89

910
service-provider
11+
service-map

docs/api/service-map.rst

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
Service Map
2+
===========
3+
4+
This page connects the single local framework class to the wider set of services and helper entry
5+
points installed by the metapackage.
6+
7+
Framework-level classes and providers
8+
-------------------------------------
9+
10+
.. list-table::
11+
:header-rows: 1
12+
:widths: 40 25 35
13+
14+
* - Identifier or class
15+
- Source
16+
- Responsibility
17+
* - ``FastForward\Framework\ServiceProvider\FrameworkServiceProvider``
18+
- This package
19+
- Main bootstrap provider for the framework metapackage
20+
* - ``FastForward\Http\ServiceProvider\HttpServiceProvider``
21+
- ``fast-forward/http``
22+
- Aggregates HTTP message-factory and HTTP client providers
23+
* - ``FastForward\Http\Message\Factory\ServiceProvider\HttpMessageFactoryServiceProvider``
24+
- ``fast-forward/http-factory``
25+
- Registers PSR-17 factories, convenience factories, and ``ServerRequestInterface``
26+
* - ``FastForward\Http\Client\ServiceProvider\HttpClientServiceProvider``
27+
- ``fast-forward/http-client``
28+
- Registers the PSR-18 client and Symfony HttpClient entry point
29+
30+
Installed entry points outside the framework provider
31+
-----------------------------------------------------
32+
33+
These classes and functions are worth knowing because they are installed together with the
34+
framework package, even though they are not auto-registered by ``FrameworkServiceProvider``.
35+
36+
.. list-table::
37+
:header-rows: 1
38+
:widths: 34 26 40
39+
40+
* - Entry point
41+
- Package
42+
- Typical use
43+
* - ``FastForward\Container\container()``
44+
- ``fast-forward/container``
45+
- Build a composed container from service providers, config objects, and PSR-11 containers
46+
* - ``FastForward\Config\ArrayConfig`` and ``FastForward\Config\config()``
47+
- ``fast-forward/config``
48+
- Store and load configuration with dot-notation access
49+
* - ``FastForward\Defer\Defer`` and ``FastForward\Defer\defer()``
50+
- ``fast-forward/defer``
51+
- Register scope-bound cleanup callbacks
52+
* - ``FastForward\Fork\Manager\ForkManager``
53+
- ``fast-forward/fork``
54+
- Run parallel workers in supported CLI environments
55+
* - ``FastForward\Iterator\ChunkedIteratorAggregate``
56+
- ``fast-forward/iterators``
57+
- Process iterable data in chunks
58+
59+
How to read this map
60+
--------------------
61+
62+
- If you need container-resolved HTTP services, start with ``FrameworkServiceProvider``.
63+
- If you need configuration, deferred callbacks, iterators, or process tools, use those packages
64+
directly through their own APIs.
65+
- If you want to add more services into the container, register your own service provider after the
66+
framework provider.

docs/api/service-provider.rst

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,49 @@ FrameworkServiceProvider
33

44
.. php:class:: FastForward\Framework\ServiceProvider\FrameworkServiceProvider
55
6-
Aggregates all core service providers required to initialize the application container.
6+
Aggregates the default Fast Forward framework providers into a single container entry point.
7+
In the current package, it composes the HTTP stack by delegating to
8+
``FastForward\Http\ServiceProvider\HttpServiceProvider``.
79

8-
**Usage:**
10+
The class extends ``FastForward\Container\ServiceProvider\AggregateServiceProvider``,
11+
so it inherits the provider-merging behavior used across the ecosystem.
912

10-
.. code-block:: php
13+
Usage
14+
-----
1115

12-
use FastForward\Framework\ServiceProvider\FrameworkServiceProvider;
13-
use FastForward\Container\Container;
16+
.. code-block:: php
1417
15-
$container = new Container([
16-
new FrameworkServiceProvider(),
17-
]);
18+
use FastForward\Framework\ServiceProvider\FrameworkServiceProvider;
19+
use function FastForward\Container\container;
1820
19-
**Constructor:**
21+
$container = container(new FrameworkServiceProvider());
2022
21-
.. php:method:: __construct()
23+
What it aggregates
24+
------------------
2225

23-
Initializes the aggregate service provider with all essential framework service providers (e.g., HTTP, logging, caching, etc.).
26+
- ``FastForward\Http\ServiceProvider\HttpServiceProvider``
27+
- Through that provider, the HTTP message factories and HTTP client service providers
2428

25-
**Extends:**
29+
Important behavior inherited from ``AggregateServiceProvider``
30+
--------------------------------------------------------------
2631

27-
- :php:class:`FastForward\Container\ServiceProvider\AggregateServiceProvider`
32+
- The provider registers itself as a retrievable service under its own class name.
33+
- The aggregated ``HttpServiceProvider`` is also available by class name.
34+
- Factory arrays are merged in provider order, so later providers can replace earlier service identifiers.
35+
- Extension callables are composed in order, so later extensions wrap earlier ones.
36+
37+
Constructor
38+
-----------
39+
40+
.. php:method:: __construct()
41+
42+
Initializes the provider by passing the framework's default provider list to the parent
43+
aggregate provider.
44+
45+
Current scope
46+
-------------
47+
48+
Although the metapackage installs multiple libraries, this local service provider currently wires
49+
the HTTP stack only. Packages such as ``fast-forward/config``, ``fast-forward/defer``,
50+
``fast-forward/fork``, and ``fast-forward/iterators`` remain available through Composer autoloading
51+
and can be introduced into your application as needed.

docs/compatibility.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Compatibility
2+
=============
3+
4+
The table below reflects the constraints declared in this repository's ``composer.json`` on
5+
April 5, 2026.
6+
7+
Runtime compatibility summary
8+
-----------------------------
9+
10+
.. list-table::
11+
:header-rows: 1
12+
:widths: 28 72
13+
14+
* - Topic
15+
- Current expectation
16+
* - PHP
17+
- ``^8.3``
18+
* - Composer
19+
- Composer 2 is the expected installation workflow
20+
* - Container contract
21+
- PSR-11 through ``fast-forward/container``
22+
* - HTTP message and factories
23+
- PSR-7 and PSR-17 through the aggregated HTTP packages
24+
* - HTTP client
25+
- PSR-18 through the aggregated HTTP client package
26+
* - Fork support
27+
- Unix-like CLI runtime with ``pcntl`` and ``posix`` support when using ``fast-forward/fork``
28+
29+
Practical compatibility notes
30+
-----------------------------
31+
32+
- ``ServerRequestInterface`` is created from globals, so it is most natural in web runtimes.
33+
- CLI tools and tests should build requests explicitly with ``RequestFactoryInterface``.
34+
- The package is safe to install even if you never use ``fast-forward/fork``; the runtime caveat
35+
only matters when you choose to use that library.

0 commit comments

Comments
 (0)