Skip to content

Commit bc27ddc

Browse files
dunglasalexander-schranzNyholm
authored
feat: add a runtime for FrankenPHP with Symfony (#124)
Add a runtime for the worker mode of [FrankenPHP](https://frankenphp.dev). To be released this afternoon at ForumPHP! ![frankenphp](https://user-images.githubusercontent.com/57224/195830342-61650267-68a6-4f05-9c34-f8f099a6c9d4.png) Co-authored-by: Alexander Schranz <[email protected]> Co-authored-by: Nyholm <[email protected]>
1 parent d51ff40 commit bc27ddc

File tree

15 files changed

+296
-1
lines changed

15 files changed

+296
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ Build high-performance, scalable, concurrent HTTP services with [Swoole](https:/
9191
* https://github.com/php-runtime/swoole
9292
* https://github.com/php-runtime/swoole-nyholm
9393

94+
### FrankenPHP
95+
96+
Run your Symfony application with the [FrankenPHP](https://frankenphp.dev) app server.
97+
98+
* https://github.com/php-runtime/frankenphp-symfony
99+
94100
### PHP-FPM and traditional web servers
95101

96102
These runtimes are for PHP-FPM and the more traditional web servers one might

phpstan-baseline.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ parameters:
99
message: "#CurlHandle#"
1010
count: 2
1111
path: src/bref/src/Lambda/LambdaClient.php
12+
13+
-
14+
message: "#^Function frankenphp_handle_request not found\\.$#"
15+
count: 1
16+
path: src/frankenphp-symfony/src/Runner.php

psalm.baseline.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="4.22.0@fc2c6ab4d5fa5d644d8617089f012f3bb84b8703">
2+
<files psalm-version="4.29.0@7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3">
33
<file src="src/bref/src/SymfonyRequestBridge.php">
44
<InvalidArgument occurrences="1">
55
<code>$response-&gt;headers-&gt;all()</code>
66
</InvalidArgument>
77
</file>
8+
<file src="src/frankenphp-symfony/src/Runner.php">
9+
<UndefinedFunction occurrences="1"/>
10+
</file>
811
<file src="src/google-cloud/router.php">
912
<MissingFile occurrences="1">
1013
<code>require_once $_SERVER['SCRIPT_FILENAME'] = $defaultSource</code>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: [nyholm]

src/frankenphp-symfony/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/
2+
composer.lock

src/frankenphp-symfony/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Change Log
2+
3+
## 0.1.0
4+
5+
First version

src/frankenphp-symfony/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2021 Tobias Nyholm
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

src/frankenphp-symfony/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# FrankenPHP Runtime for Symfony
2+
3+
A runtime for [FrankenPHP](https://frankenphp.dev/).
4+
5+
If you are new to the Symfony Runtime component, read more in the [main readme](https://github.com/php-runtime/runtime).
6+
7+
## Installation
8+
9+
```
10+
composer require runtime/frankenphp-symfony
11+
```
12+
13+
## Usage
14+
15+
Define the environment variable `APP_RUNTIME` for your application.
16+
17+
```
18+
// .env
19+
APP_RUNTIME=Runtime\FrankenPhpSymfony\Runtime
20+
```
21+
22+
```
23+
// .rr.yaml
24+
server:
25+
...
26+
env:
27+
APP_RUNTIME: Runtime\FrankenPhpSymfony\Runtime
28+
```
29+
30+
```php
31+
// public/index.php
32+
33+
use App\Kernel;
34+
35+
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
36+
37+
return function (array $context) {
38+
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
39+
};
40+
```

src/frankenphp-symfony/composer.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "runtime/frankenphp-symfony",
3+
"description": "FrankenPHP runtime for Symfony",
4+
"license": "MIT",
5+
"type": "library",
6+
"authors": [
7+
{
8+
"name": "Kévin Dunglas",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"require": {
13+
"php": ">=8.2.0",
14+
"symfony/dependency-injection": "^5.4 || ^6.0",
15+
"symfony/http-kernel": "^5.4 || ^6.0",
16+
"symfony/runtime": "^5.4 || ^6.0"
17+
},
18+
"require-dev": {
19+
"phpunit/phpunit": "^9.5"
20+
},
21+
"minimum-stability": "dev",
22+
"prefer-stable": true,
23+
"autoload": {
24+
"psr-4": {
25+
"Runtime\\FrankenPhpSymfony\\": "src/"
26+
}
27+
},
28+
"autoload-dev": {
29+
"psr-4": {
30+
"Runtime\\FrankenPhpSymfony\\Tests\\": "tests/"
31+
}
32+
},
33+
"config": {
34+
"allow-plugins": {
35+
"symfony/runtime": true
36+
}
37+
}
38+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
4+
backupGlobals="false"
5+
colors="true"
6+
bootstrap="vendor/autoload.php"
7+
failOnRisky="true"
8+
failOnWarning="true"
9+
>
10+
<php>
11+
<ini name="error_reporting" value="-1"/>
12+
</php>
13+
<testsuites>
14+
<testsuite name="Test Suite">
15+
<directory>./tests</directory>
16+
</testsuite>
17+
</testsuites>
18+
</phpunit>

0 commit comments

Comments
 (0)