Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions php/sunrise-router-annotations/composer.json

This file was deleted.

6 changes: 0 additions & 6 deletions php/sunrise-router-annotations/config.yaml

This file was deleted.

37 changes: 0 additions & 37 deletions php/sunrise-router-annotations/public/index.php

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 12 additions & 0 deletions php/sunrise-router-roadrunner/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.{json,yaml}]
indent_size = 2
3 changes: 3 additions & 0 deletions php/sunrise-router-roadrunner/.env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
APP_ENV=prod
APP_NAME=php.sunrise.router.roadrunner
APP_VERSION=1.0.0
21 changes: 8 additions & 13 deletions php/sunrise-router-roadrunner/.rr.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
version: "3"
rpc:
listen: "tcp://127.0.0.1:6001"
http:
address: "0.0.0.0:3000"
middleware: ["static"]
static:
dir: "public"
calculate_etag: false
allow: [".ico"]
# https://github.com/roadrunner-server/roadrunner/blob/master/.rr.yaml

version: '3'
server:
command: "php public/index.php"
relay: pipes
command: php bin/app rr:work
http:
address: 0.0.0.0:3000
rpc:
listen: tcp://127.0.0.1:6001
logs:
mode: production
level: error
21 changes: 21 additions & 0 deletions php/sunrise-router-roadrunner/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Anatolii Nekhai

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 5 additions & 0 deletions php/sunrise-router-roadrunner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# An awesome skeleton for modern PHP development

## Resources

- [Documentation](https://dev.sunrise-studio.io/docs/packages/sunrise/awesome-skeleton/)
31 changes: 28 additions & 3 deletions php/sunrise-router-roadrunner/composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
{
"type": "project",
"name": "sunrise/awesome-skeleton",
"homepage": "https://github.com/sunrise-php/awesome-skeleton",
"description": "An awesome skeleton for modern PHP development.",
"keywords": [
"fenric",
"sunrise",
"skeleton",
"php-skeleton",
"api-skeleton",
"api-platform"
],
"require": {
"sunrise/http-router": "~2.16.0",
"sunrise/http-factory": "@stable",
"php": ">=8.3",
"php-di/php-di": "@stable",
"spiral/roadrunner-cli": "@stable",
"spiral/roadrunner-http": "@stable"
"spiral/roadrunner-http": "@stable",
"sunrise/http-message": "@stable",
"sunrise/http-router": "~3.0.0",
"symfony/cache": "@stable",
"symfony/console": "@stable",
"symfony/dotenv": "@stable"
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"config": {
"sort-packages": true
}
}
11 changes: 1 addition & 10 deletions php/sunrise-router-roadrunner/config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
framework:
github: sunrise-php/http-router
version: 2.16

version: 3.0
engines:
- road-runner

deps:
- libevent-dev
- libsodium-dev

modules:
- sodium
- sockets
9 changes: 9 additions & 0 deletions php/sunrise-router-roadrunner/config/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

use Symfony\Component\Dotenv\Dotenv;

require_once __DIR__ . '/../vendor/autoload.php';

(new Dotenv())->loadEnv(__DIR__ . '/../.env');
34 changes: 34 additions & 0 deletions php/sunrise-router-roadrunner/config/container.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

use DI\Container;
use DI\ContainerBuilder;

return (static function (): Container {
$appEnv = $_ENV['APP_ENV'] ?? 'dev';

$containerBuilder = new ContainerBuilder();

// https://github.com/sunrise-php/http-message
$containerBuilder->addDefinitions(
__DIR__ . '/../vendor/sunrise/http-message/resources/definitions/psr17.php',
);

// https://github.com/sunrise-php/http-router
$containerBuilder->addDefinitions(
__DIR__ . '/../vendor/sunrise/http-router/resources/definitions/router.php',
__DIR__ . '/../vendor/sunrise/http-router/resources/definitions/loaders/descriptor_loader.php',
);

$containerBuilder->addDefinitions(
...glob(__DIR__ . '/definitions/*.php'),
...glob(__DIR__ . '/definitions/' . $appEnv . '/*.php'),
);

if ($appEnv === 'prod') {
$containerBuilder->enableCompilation(__DIR__ . '/../var/cache/container');
}

return $containerBuilder->build();
})();
21 changes: 21 additions & 0 deletions php/sunrise-router-roadrunner/config/definitions/app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

use App\Command\RoadRunnerWorker;

use function DI\add;
use function DI\autowire;
use function DI\env;

return [
'app.root' => realpath(__DIR__ . '/../..'),

'app.env' => env('APP_ENV'),
'app.name' => env('APP_NAME'),
'app.version' => env('APP_VERSION'),

'app.commands' => add([
autowire(RoadRunnerWorker::class),
]),
];
20 changes: 20 additions & 0 deletions php/sunrise-router-roadrunner/config/definitions/cache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

use Psr\Cache\CacheItemPoolInterface;
use Psr\SimpleCache\CacheInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Psr16Cache;

use function DI\create;
use function DI\get;

return [
CacheItemPoolInterface::class => create(ArrayAdapter::class),

CacheInterface::class => create(Psr16Cache::class)
->constructor(
get(CacheItemPoolInterface::class),
),
];
13 changes: 13 additions & 0 deletions php/sunrise-router-roadrunner/config/definitions/prod/cache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

use function DI\create;

return [
// TODO: It must be replaced by something like Redis.
CacheItemPoolInterface::class => create(ArrayAdapter::class),
];
12 changes: 12 additions & 0 deletions php/sunrise-router-roadrunner/config/definitions/router.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

use function DI\add;
use function DI\string;

return [
'router.descriptor_loader.resources' => add([
string('{app.root}/src/Controller'),
]),
];
Loading
Loading