Skip to content

Commit 7405a65

Browse files
committed
Merge branch 'develop'
* develop: specify next release update notes style update notes style add documentation for grouped routes update changelog add Routes::append() add support for grouped routes update actions run tests via blackbox fix keeping all routes in memory use an Implementation interface to better track the expected types simplify readme example fix documentation update dependencies
2 parents ebbf053 + 18c09b8 commit 7405a65

31 files changed

Lines changed: 610 additions & 319 deletions

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
/.gitattributes export-ignore
22
/.gitignore export-ignore
3-
/phpunit.xml.dist export-ignore
43
/tests export-ignore

.github/workflows/ci.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ name: CI
33
on: [push]
44

55
jobs:
6-
phpunit:
6+
blackbox:
77
runs-on: ${{ matrix.os }}
88
strategy:
99
matrix:
1010
os: [ubuntu-latest, macOS-latest]
1111
php-version: ['8.2', '8.3']
1212
dependencies: ['lowest', 'highest']
13-
name: 'PHPUnit'
13+
name: 'BlackBox'
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4
1717
- name: Setup PHP
1818
uses: shivammathur/setup-php@v2
1919
with:
@@ -24,8 +24,8 @@ jobs:
2424
uses: "ramsey/composer-install@v2"
2525
with:
2626
dependency-versions: ${{ matrix.dependencies }}
27-
- name: PHPUnit
28-
run: vendor/bin/phpunit
27+
- name: BlackBox
28+
run: php blackbox.php
2929
coverage:
3030
runs-on: ${{ matrix.os }}
3131
strategy:
@@ -36,7 +36,7 @@ jobs:
3636
name: 'Coverage'
3737
steps:
3838
- name: Checkout
39-
uses: actions/checkout@v2
39+
uses: actions/checkout@v4
4040
- name: Setup PHP
4141
uses: shivammathur/setup-php@v2
4242
with:
@@ -47,11 +47,11 @@ jobs:
4747
uses: "ramsey/composer-install@v2"
4848
with:
4949
dependency-versions: ${{ matrix.dependencies }}
50-
- name: PHPUnit
51-
run: vendor/bin/phpunit --coverage-clover=coverage.clover
50+
- name: BlackBox
51+
run: php blackbox.php
5252
env:
53-
BLACKBOX_SET_SIZE: 1
54-
- uses: codecov/codecov-action@v1
53+
ENABLE_COVERAGE: 'true'
54+
- uses: codecov/codecov-action@v3
5555
with:
5656
token: ${{ secrets.CODECOV_TOKEN }}
5757
psalm:
@@ -63,7 +63,7 @@ jobs:
6363
name: 'Psalm'
6464
steps:
6565
- name: Checkout
66-
uses: actions/checkout@v2
66+
uses: actions/checkout@v4
6767
- name: Setup PHP
6868
uses: shivammathur/setup-php@v2
6969
with:
@@ -83,7 +83,7 @@ jobs:
8383
name: 'CS'
8484
steps:
8585
- name: Checkout
86-
uses: actions/checkout@v2
86+
uses: actions/checkout@v4
8787
- name: Setup PHP
8888
uses: shivammathur/setup-php@v2
8989
with:

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
composer.lock
22
vendor
3-
.phpunit.result.cache
4-
.phpunit.cache

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog
22

3+
## 2.0.0 - 2023-10-26
4+
5+
### Added
6+
7+
- `Innmind\Framework\Http\Routes::append()`
8+
- `Innmind\Framework\Http\Routes::add()` now also accepts `Innmind\Router\Under`
9+
10+
### Changed
11+
12+
- Requires `innmind/operating-system:~4.1`
13+
- Requires `innmind/immutable:~5.2`
14+
- Requires `innmind/filesystem:~7.0`
15+
- Requires `innmind/http-server:~4.0`
16+
- Requires `innmind/router:~4.1`
17+
- Requires `innmind/innmind/async-http-server:~2.0`
18+
19+
### Fixed
20+
21+
- All routes are no longer kept in memory when no longer used
22+
323
## 1.4.0 - 2023-09-24
424

525
### Added

README.md

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ Take a look at the [documentation](docs/) for a more in-depth understanding of t
2424

2525
The first step is to create the index file that will be exposed via a webserver (for example `public/index.php`). Then you need to specify the routes you want to handle.
2626

27-
> **Note** if you don't configure any route it will respond with `404 Not Found` with an empty body.
27+
> [!NOTE]
28+
> if you don't configure any route it will respond with `404 Not Found` with an empty body.
2829
2930
```php
3031
<?php
@@ -35,41 +36,31 @@ require 'path/to/composer/autoload.php';
3536
use Innmind\Framework\{
3637
Main\Http,
3738
Application,
38-
Http\Routes,
3939
};
40-
use Innmind\Router\{
41-
Route,
42-
Route\Variables,
43-
};
44-
use Innmind\Http\Message\{
40+
use Innmind\Router\Route\Variables;
41+
use Innmind\Http\{
4542
ServerRequest,
46-
Response\Response,
47-
StatusCode,
43+
Response,
44+
Response\StatusCode,
4845
};
4946
use Innmind\Filesystem\File\Content;
5047

5148
new class extends Http {
5249
protected function configure(Application $app): Application
5350
{
54-
return $app->appendRoutes(
55-
static fn(Routes $routes) => $routes
56-
->add(Route::literal('GET /')->handle(
57-
static fn(ServerRequest $request) => new Response(
58-
StatusCode::ok,
59-
$request->protocolVersion(),
60-
null,
61-
Content\Lines::ofContent('Hello world!'),
62-
),
63-
))
64-
->add(Route::literal('GET /{name}')->handle(
65-
static fn(ServerRequest $request, Variables $variables) => new Response(
66-
StatusCode::ok,
67-
$request->protocolVersion(),
68-
null,
69-
Content\Lines::ofContent("Hello {$variables->get('name')}!"),
70-
),
71-
)),
72-
);
51+
return $app
52+
->route('GET /', static fn(ServerRequest $request) => Response::of(
53+
StatusCode::ok,
54+
$request->protocolVersion(),
55+
null,
56+
Content::ofString('Hello world!'),
57+
))
58+
->route('GET /{name}', static fn(ServerRequest $request, Variables $variables) => Response::of(
59+
StatusCode::ok,
60+
$request->protocolVersion(),
61+
null,
62+
Content::ofString("Hello {$variables->get('name')}!"),
63+
));
7364
}
7465
};
7566
```
@@ -80,7 +71,8 @@ You can run this script via `cd public && php -S localhost:8080`. If you open yo
8071

8172
The entrypoint of your cli tools will look something like this.
8273

83-
> **Note** by default if you don't configure any command it will always display `Hello world`.
74+
> [!NOTE]
75+
> by default if you don't configure any command it will always display `Hello world`.
8476
8577
```php
8678
<?php

blackbox.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
declare(strict_types = 1);
3+
4+
require 'vendor/autoload.php';
5+
6+
use Innmind\BlackBox\{
7+
Application,
8+
PHPUnit\Load,
9+
Runner\CodeCoverage,
10+
};
11+
12+
Application::new($argv)
13+
->when(
14+
\getenv('ENABLE_COVERAGE') !== false,
15+
static fn(Application $app) => $app
16+
->codeCoverage(
17+
CodeCoverage::of(
18+
__DIR__.'/src/',
19+
__DIR__.'/tests/',
20+
)
21+
->dumpTo('coverage.clover')
22+
->enableWhen(true),
23+
)
24+
->scenariiPerProof(1),
25+
)
26+
->tryToProve(Load::directory(__DIR__.'/tests/'))
27+
->exit();

composer.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
},
1717
"require": {
1818
"php": "~8.2",
19-
"innmind/operating-system": "^3.2",
19+
"innmind/operating-system": "~4.1",
2020
"innmind/cli": "^3.1",
21-
"innmind/immutable": "^4.9|~5.0",
21+
"innmind/immutable": "~5.2",
2222
"innmind/di": "^2.0",
2323
"ramsey/uuid": "^4.7",
2424
"innmind/url": "^4.1",
25-
"innmind/filesystem": "^6.0",
26-
"innmind/http-server": "^3.0",
27-
"innmind/router": "^3.0"
25+
"innmind/filesystem": "~7.0",
26+
"innmind/http-server": "~4.0",
27+
"innmind/router": "~4.1"
2828
},
2929
"autoload": {
3030
"psr-4": {
@@ -37,15 +37,14 @@
3737
}
3838
},
3939
"require-dev": {
40-
"phpunit/phpunit": "~10.2",
4140
"vimeo/psalm": "~5.6",
4241
"innmind/black-box": "~5.5",
4342
"innmind/coding-standard": "~2.0",
44-
"innmind/async-http-server": "~1.0"
43+
"innmind/async-http-server": "~2.0"
4544
},
4645
"conflict": {
4746
"innmind/black-box": "<5.0|~6.0",
48-
"innmind/async-http-server": "<1.0|~2.0"
47+
"innmind/async-http-server": "<2.0|~3.0"
4948
},
5049
"suggest": {
5150
"innmind/black-box": "For property based testing",

docs/experimental/async-server.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
The framework comes with an HTTP server entirely built in PHP allowing you to serve your app without extra dependencies in ther earlist stages of your project.
44

5-
> **Note** This feature is optional, to use it you must before run `composer require innmind/async-http-server`.
5+
> [!NOTE]
6+
> This feature is optional, to use it you must before run `composer require innmind/async-http-server`.
67
78
To use it is similar to the standard [http](../http.md) handler, the first difference is the namespace of the main entrypoint:
89

@@ -29,6 +30,8 @@ Note the namespace is `Main\Async\Http` instead of `Main\Http`. The other differ
2930

3031
All the configuration of the `Application` object is identical to the other contexts.
3132

32-
> **Note** The server currently does have limitations, streamed requests (via `Transfer-Encoding`) are not supported and multipart requests are not parsed.
33+
> [!NOTE]
34+
>The server currently does have limitations, streamed requests (via `Transfer-Encoding`) are not supported and multipart requests are not parsed.
3335
34-
> **Warning** This server was built to showcase in a conference talk the ability to switch between synchronous code and asynchronous code without changing the app code. Do **NOT** use this server in production.
36+
> [!WARNING]
37+
> This server was built to showcase in a conference talk the ability to switch between synchronous code and asynchronous code without changing the app code. Do **NOT** use this server in production.

0 commit comments

Comments
 (0)