Skip to content

Commit a79d77a

Browse files
authored
Merge pull request #1 from crazy-goat/use-kernel-as-app
Use kernel as app
2 parents 57ef80a + 30d6bcb commit a79d77a

28 files changed

Lines changed: 386 additions & 55 deletions

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
/vendor/
22
composer.lock
3+
/.idea/.gitignore
4+
/.idea/modules.xml
5+
/.idea/php.xml
6+
/.idea/phpunit.xml
7+
/.idea/reactphp-runtime.iml
8+
/.idea/vcs.xml

composer.json

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,41 @@
11
{
2-
"name": "runtime/react",
3-
"description": "ReactPHP runtime",
2+
"name": "crazy-goat/reactphp-runtime",
3+
"description": "ReactPHP runtime for Symfony apps",
44
"license": "MIT",
55
"type": "library",
66
"authors": [
77
{
88
"name": "Tobias Nyholm",
99
"email": "tobias.nyholm@gmail.com"
10+
},
11+
{
12+
"name": "Piotr Halas",
13+
"email": "halaspiotr@gmail.com"
1014
}
1115
],
1216
"require": {
17+
"ext-pcntl": "*",
1318
"php": ">=8.0.5",
1419
"psr/http-server-handler": "^1.0",
1520
"react/http": "^1.6",
16-
"symfony/runtime": "^5.4 || ^6.0 || ^7.0"
21+
"symfony/runtime": "^5.4 || ^6.0 || ^7.0",
22+
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
23+
"symfony/psr-http-message-bridge": "^2.1 || ^6.4 || ^7.0"
1724
},
1825
"require-dev": {
19-
"phpunit/phpunit": "^9.5"
26+
"phpunit/phpunit": "^9.5",
27+
"nyholm/psr7": "^1.8"
2028
},
2129
"minimum-stability": "dev",
2230
"prefer-stable": true,
2331
"autoload": {
2432
"psr-4": {
25-
"Runtime\\React\\": "src/",
26-
"Symfony\\Runtime\\Psr\\Http\\": "runtime/"
33+
"CrazyGoat\\ReactPHPRuntime\\": "src/"
2734
}
2835
},
2936
"autoload-dev": {
3037
"psr-4": {
31-
"Runtime\\React\\Tests\\": "tests/"
38+
"CrazyGoat\\ReactPHPRuntime\\Tests\\": "tests/"
3239
}
3340
},
3441
"config": {

example/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
###> symfony/framework-bundle ###
3+
/.env.local
4+
/.env.local.php
5+
/.env.*.local
6+
/config/secrets/prod/prod.decrypt.private.php
7+
/public/bundles/
8+
/var/
9+
/vendor/
10+
###< symfony/framework-bundle ###

example/bin/console

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use App\Kernel;
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
7+
if (!is_dir(dirname(__DIR__).'/vendor')) {
8+
throw new LogicException('Dependencies are missing. Try running "composer install".');
9+
}
10+
11+
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
12+
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
13+
}
14+
15+
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
16+
17+
return function (array $context) {
18+
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
19+
20+
return new Application($kernel);
21+
};

example/composer.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"type": "project",
3+
"license": "proprietary",
4+
"minimum-stability": "stable",
5+
"prefer-stable": true,
6+
"require": {
7+
"php": ">=8.2",
8+
"ext-ctype": "*",
9+
"ext-iconv": "*",
10+
"nyholm/psr7": "^1.8",
11+
"runtime/react": "^0.2.0",
12+
"symfony/console": "7.3.*",
13+
"symfony/dotenv": "7.3.*",
14+
"symfony/flex": "^2",
15+
"symfony/framework-bundle": "7.3.*",
16+
"symfony/psr-http-message-bridge": "7.3.*",
17+
"symfony/runtime": "7.3.*",
18+
"symfony/yaml": "7.3.*"
19+
},
20+
"config": {
21+
"allow-plugins": {
22+
"php-http/discovery": true,
23+
"symfony/flex": true,
24+
"symfony/runtime": true
25+
},
26+
"bump-after-update": true,
27+
"sort-packages": true
28+
},
29+
"autoload": {
30+
"psr-4": {
31+
"App\\": "src/",
32+
"CrazyGoat\\ReactPHPRuntime\\": "../src/"
33+
}
34+
},
35+
"autoload-dev": {
36+
"psr-4": {
37+
"App\\Tests\\": "tests/"
38+
}
39+
},
40+
"replace": {
41+
"symfony/polyfill-ctype": "*",
42+
"symfony/polyfill-iconv": "*",
43+
"symfony/polyfill-php72": "*",
44+
"symfony/polyfill-php73": "*",
45+
"symfony/polyfill-php74": "*",
46+
"symfony/polyfill-php80": "*",
47+
"symfony/polyfill-php81": "*",
48+
"symfony/polyfill-php82": "*"
49+
},
50+
"scripts": {
51+
"auto-scripts": {
52+
"cache:clear": "symfony-cmd",
53+
"assets:install %PUBLIC_DIR%": "symfony-cmd"
54+
},
55+
"post-install-cmd": [
56+
"@auto-scripts"
57+
],
58+
"post-update-cmd": [
59+
"@auto-scripts"
60+
]
61+
},
62+
"conflict": {
63+
"symfony/symfony": "*"
64+
},
65+
"extra": {
66+
"symfony": {
67+
"allow-contrib": false,
68+
"require": "7.3.*"
69+
}
70+
}
71+
}

example/config/bundles.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
5+
];

example/config/packages/cache.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
framework:
2+
cache:
3+
# Unique name of your app: used to compute stable namespaces for cache keys.
4+
#prefix_seed: your_vendor_name/app_name
5+
6+
# The "app" cache stores to the filesystem by default.
7+
# The data in this cache should persist between deploys.
8+
# Other options include:
9+
10+
# Redis
11+
#app: cache.adapter.redis
12+
#default_redis_provider: redis://localhost
13+
14+
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
15+
#app: cache.adapter.apcu
16+
17+
# Namespaced pools use the above "app" backend by default
18+
#pools:
19+
#my.dedicated.cache: null
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# see https://symfony.com/doc/current/reference/configuration/framework.html
2+
framework:
3+
secret: '%env(APP_SECRET)%'
4+
5+
# Note that the session will be started ONLY if you read or write from it.
6+
session: true
7+
8+
#esi: true
9+
#fragments: true
10+
11+
when@test:
12+
framework:
13+
test: true
14+
session:
15+
storage_factory_id: session.storage.factory.mock_file
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
# Register nyholm/psr7 services for autowiring with PSR-17 (HTTP factories)
3+
Psr\Http\Message\RequestFactoryInterface: '@nyholm.psr7.psr17_factory'
4+
Psr\Http\Message\ResponseFactoryInterface: '@nyholm.psr7.psr17_factory'
5+
Psr\Http\Message\ServerRequestFactoryInterface: '@nyholm.psr7.psr17_factory'
6+
Psr\Http\Message\StreamFactoryInterface: '@nyholm.psr7.psr17_factory'
7+
Psr\Http\Message\UploadedFileFactoryInterface: '@nyholm.psr7.psr17_factory'
8+
Psr\Http\Message\UriFactoryInterface: '@nyholm.psr7.psr17_factory'
9+
10+
nyholm.psr7.psr17_factory:
11+
class: Nyholm\Psr7\Factory\Psr17Factory
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
framework:
2+
router:
3+
# Configure how to generate URLs in non-HTTP contexts, such as CLI commands.
4+
# See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
5+
#default_uri: http://localhost
6+
7+
when@prod:
8+
framework:
9+
router:
10+
strict_requirements: null

0 commit comments

Comments
 (0)