Skip to content

Commit c011b12

Browse files
committed
Wrap up first version
1 parent 8adda4c commit c011b12

File tree

8 files changed

+219
-10
lines changed

8 files changed

+219
-10
lines changed

.docheader

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* This file is part of php-fast-forward/framework.
3+
*
4+
* This source file is subject to the license bundled
5+
* with this source code in the file LICENSE.
6+
*
7+
* @link https://github.com/php-fast-forward/framework
8+
* @copyright Copyright (c) 2025-%year% Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
9+
* @license https://opensource.org/licenses/MIT MIT License
10+
*/

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.php-cs-fixer.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of php-fast-forward/framework.
7+
*
8+
* This source file is subject to the license bundled
9+
* with this source code in the file LICENSE.
10+
*
11+
* @link https://github.com/php-fast-forward/framework
12+
* @copyright Copyright (c) 2025 Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
13+
* @license https://opensource.org/licenses/MIT MIT License
14+
*/
15+
16+
use CoiSA\PhpCsFixer\PhpCsFixer;
17+
18+
$paths = [
19+
__FILE__,
20+
__DIR__,
21+
];
22+
23+
$header = file_get_contents(__DIR__ . '/.docheader');
24+
25+
return PhpCsFixer::create($paths, $header);

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Fast Forward Framework
22

33
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
4-
[![PHP Version](https://img.shields.io/badge/php-^8.1-blue.svg)](https://www.php.net/releases/)
4+
[![PHP Version](https://img.shields.io/badge/php-^8.2-blue.svg)](https://www.php.net/releases/)
55

66
**Fast Forward Framework** is a lightweight and fast PHP framework designed for building modern web applications.
77
This package serves as an **aggregate metapackage**, bundling all core components of the Fast Forward ecosystem for easier installation and management.
@@ -10,10 +10,7 @@ This package serves as an **aggregate metapackage**, bundling all core component
1010

1111
## Features
1212

13-
- 🚀 **Modern PHP 8.1+ syntax**
14-
- ⚙️ Aggregates key components:
15-
- [`fast-forward/config`](https://github.com/php-fast-forward/config) – configuration system with dot notation and caching
16-
- [`fast-forward/container`](https://github.com/php-fast-forward/container) – PSR-11 compatible DI container with aggregation support
13+
- 🚀 **Modern PHP 8.2+ syntax**
1714
- 📦 Simplifies installation of all core packages in one step
1815
- 🧱 Provides a solid foundation for building scalable PHP applications
1916

composer.json

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
"source": "https://github.com/php-fast-forward/framework"
1616
},
1717
"require": {
18-
"php": "^8.1",
19-
"fast-forward/config": "^1.0",
20-
"fast-forward/container": "^1.0",
18+
"php": "^8.2",
19+
"fast-forward/config": "^1.4",
20+
"fast-forward/container": "^1.5",
21+
"fast-forward/http": "^1.0",
2122
"fast-forward/iterators": "^1.0"
2223
},
2324
"minimum-stability": "stable",
@@ -28,5 +29,32 @@
2829
"branch-alias": {
2930
"dev-main": "1.x-dev"
3031
}
32+
},
33+
"autoload": {
34+
"psr-4": {
35+
"FastForward\\Framework\\": "src/"
36+
}
37+
},
38+
"autoload-dev": {
39+
"psr-4": {
40+
"FastForward\\Framework\\Tests\\": "tests/"
41+
}
42+
},
43+
"scripts": {
44+
"cs-check": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --dry-run --diff",
45+
"cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix",
46+
"mutation-testing": "infection --threads=4",
47+
"pre-commit": [
48+
"@cs-check",
49+
"@static-analysis",
50+
"@tests"
51+
],
52+
"static-analysis": "phpstan analyse --level 5 src",
53+
"tests": "phpunit --testdox"
54+
},
55+
"require-dev": {
56+
"coisa/php-cs-fixer": "^2.1",
57+
"phpspec/prophecy-phpunit": "^2.4",
58+
"phpunit/phpunit": "^12.3"
3159
}
3260
}

phpunit.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
executionOrder="depends,defects"
6+
shortenArraysForExportThreshold="10"
7+
requireCoverageMetadata="true"
8+
beStrictAboutCoverageMetadata="true"
9+
beStrictAboutOutputDuringTests="true"
10+
displayDetailsOnPhpunitDeprecations="true"
11+
failOnPhpunitDeprecation="true"
12+
failOnRisky="true"
13+
failOnWarning="true">
14+
<testsuites>
15+
<testsuite name="Fast Forward Framework Test Suite">
16+
<directory>tests</directory>
17+
</testsuite>
18+
</testsuites>
19+
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
20+
<include>
21+
<directory>src</directory>
22+
</include>
23+
</source>
24+
<coverage>
25+
<report>
26+
<clover outputFile="public/coverage/clover.xml"/>
27+
<html outputDirectory="public/coverage" lowUpperBound="35" highLowerBound="70"/>
28+
<text outputFile="php://stdout"/>
29+
</report>
30+
</coverage>
31+
<logging>
32+
<testdoxHtml outputFile="public/coverage/testdox.html"/>
33+
</logging>
34+
</phpunit>

src/ServiceProvider/FrameworkServiceProvider.php

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,88 @@
11
<?php
22

3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of php-fast-forward/framework.
7+
*
8+
* This source file is subject to the license bundled
9+
* with this source code in the file LICENSE.
10+
*
11+
* @link https://github.com/php-fast-forward/framework
12+
* @copyright Copyright (c) 2025 Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
13+
* @license https://opensource.org/licenses/MIT MIT License
14+
*/
15+
316
namespace FastForward\Framework\ServiceProvider;
417

518
use FastForward\Container\ServiceProvider\AggregateServiceProvider;
6-
use FastForward\EventDispatcher\ServiceProvider\EventDispatcherServiceProvider;
719
use FastForward\Http\ServiceProvider\HttpServiceProvider;
820
use Interop\Container\ServiceProviderInterface;
921

22+
/**
23+
* Class FrameworkServiceProvider.
24+
*
25+
* Aggregates core framework service providers into a unified service provider.
26+
* This class MUST be used to encapsulate all foundational service providers
27+
* required to initialize the application container.
28+
*
29+
* The internal aggregation MAY include HTTP, logging, caching, console,
30+
* event dispatching, session handling, and other service providers required
31+
* for application infrastructure.
32+
*
33+
* This class SHALL implement the ServiceProviderInterface and MUST delegate
34+
* its service discovery responsibilities to an internal AggregateServiceProvider.
35+
*/
1036
final class FrameworkServiceProvider implements ServiceProviderInterface
1137
{
38+
/**
39+
* @var ServiceProviderInterface the aggregate container for framework service providers
40+
*/
1241
private ServiceProviderInterface $serviceProvider;
1342

43+
/**
44+
* Constructs the FrameworkServiceProvider.
45+
*
46+
* This constructor MUST initialize the aggregate service provider using
47+
* a composition of essential framework service providers.
48+
*/
1449
public function __construct()
1550
{
1651
$this->serviceProvider = new AggregateServiceProvider(
1752
new HttpServiceProvider(),
18-
new EventDispatcherServiceProvider(),
53+
// ErrorHandlerServiceProvider,
54+
// EventDispatcherServiceProvider,
55+
// LoggerServiceProvider,
56+
// CacheServiceProvider,
57+
// ConsoleServiceProvider,
58+
// TemplateRendererServiceProvider,
59+
// SecurityServiceProvider,
60+
// SessionServiceProvider,
61+
// ...
1962
);
2063
}
2164

65+
/**
66+
* Returns an array of service factory callables.
67+
*
68+
* This method MUST delegate to the internal AggregateServiceProvider and
69+
* return all service factories required for container instantiation.
70+
*
71+
* @return array<string, callable> an associative array of factory callables indexed by service IDs
72+
*/
2273
public function getFactories(): array
2374
{
2475
return $this->serviceProvider->getFactories();
2576
}
2677

78+
/**
79+
* Returns an array of service extension callables.
80+
*
81+
* This method MUST delegate to the internal AggregateServiceProvider and
82+
* return all service extensions used to decorate existing services.
83+
*
84+
* @return array<string, callable> an associative array of extension callables indexed by service IDs
85+
*/
2786
public function getExtensions(): array
2887
{
2988
return $this->serviceProvider->getExtensions();
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace FastForward\Framework\ServiceProvider\Tests;
6+
7+
use FastForward\Framework\ServiceProvider\FrameworkServiceProvider;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
use PHPUnit\Framework\TestCase;
10+
use Prophecy\PhpUnit\ProphecyTrait;
11+
12+
#[CoversClass(FrameworkServiceProvider::class)]
13+
final class FrameworkServiceProviderTest extends TestCase
14+
{
15+
use ProphecyTrait;
16+
17+
private FrameworkServiceProvider $provider;
18+
19+
protected function setUp(): void
20+
{
21+
$this->provider = new FrameworkServiceProvider();
22+
}
23+
24+
public function testGetFactoriesWillReturnHttpServiceProviderFactories(): void
25+
{
26+
$factories = $this->provider->getFactories();
27+
28+
self::assertIsArray($factories);
29+
self::assertNotEmpty($factories);
30+
foreach ($factories as $factory) {
31+
self::assertIsCallable($factory);
32+
}
33+
}
34+
35+
public function testGetExtensionsWillReturnHttpServiceProviderExtensions(): void
36+
{
37+
$extensions = $this->provider->getExtensions();
38+
39+
self::assertIsArray($extensions);
40+
foreach ($extensions as $extension) {
41+
self::assertIsCallable($extension);
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)