diff --git a/frameworks/PHP/spiral/.env b/frameworks/PHP/spiral/.env index 99b475a0bef..c515771e507 100644 --- a/frameworks/PHP/spiral/.env +++ b/frameworks/PHP/spiral/.env @@ -1,4 +1,5 @@ # Debug mode disabled view cache and enabled higher verbosity. +APP_ENV=prod DEBUG=false DB_DSN=mysql:host=tfb-database:3306;charset=utf8;dbname=hello_world;user=benchmarkdbuser;password=benchmarkdbpass diff --git a/frameworks/PHP/spiral/.rr.yaml b/frameworks/PHP/spiral/.rr.yaml index 392e5df92b4..f4b6753ca6f 100644 --- a/frameworks/PHP/spiral/.rr.yaml +++ b/frameworks/PHP/spiral/.rr.yaml @@ -4,6 +4,8 @@ rpc: listen: tcp://127.0.0.1:6001 server: + on_init: + command: "php app.php cycle" command: "php app.php" relay: pipes diff --git a/frameworks/PHP/spiral/app.php b/frameworks/PHP/spiral/app.php index 0aa75e9826e..0f747f19b01 100644 --- a/frameworks/PHP/spiral/app.php +++ b/frameworks/PHP/spiral/app.php @@ -3,16 +3,25 @@ declare(strict_types=1); use App\App; +use Spiral\Core\Container; +use Spiral\Core\Options; \mb_internal_encoding('UTF-8'); -\error_reporting(E_ALL | E_STRICT ^ E_DEPRECATED); +\error_reporting(E_ALL ^ E_DEPRECATED); \ini_set('display_errors', 'stderr'); // Register Composer's auto loader. require __DIR__ . '/vendor/autoload.php'; // Initialize shared container, bindings, directories and etc. -$app = App::create(directories: ['root' => __DIR__])->run(); +$options = new Options(); +$options->validateArguments = false; +$options->allowSingletonsRebinding = true; +$container = new Container(options: $options); +$app = App::create( + directories: ['root' => __DIR__], + container: $container, +)->run(); if ($app === null) { exit(255); diff --git a/frameworks/PHP/spiral/app/config/cycle.php b/frameworks/PHP/spiral/app/config/cycle.php new file mode 100644 index 00000000000..773081decb6 --- /dev/null +++ b/frameworks/PHP/spiral/app/config/cycle.php @@ -0,0 +1,52 @@ + [ + /** + * true (Default) - Schema will be stored in a cache after compilation. + * It won't be changed after entity modification. Use `php app.php cycle` to update schema. + * + * false - Schema won't be stored in a cache after compilation. + * It will be automatically changed after entity modification. (Development mode) + */ + 'cache' => true, + + /** + * The CycleORM provides the ability to manage default settings for + * every schema with not defined segments + */ + 'defaults' => [ + SchemaInterface::MAPPER => \Cycle\ORM\Mapper\Mapper::class, + SchemaInterface::REPOSITORY => \Cycle\ORM\Select\Repository::class, + SchemaInterface::SCOPE => null, + SchemaInterface::TYPECAST_HANDLER => [ + \Cycle\ORM\Parser\Typecast::class + ], + ], + + 'collections' => [ + 'default' => 'array', + 'factories' => [ + 'array' => new \Cycle\ORM\Collection\ArrayCollectionFactory(), + // 'doctrine' => new \Cycle\ORM\Collection\DoctrineCollectionFactory(), + // 'illuminate' => new \Cycle\ORM\Collection\IlluminateCollectionFactory(), + ], + ], + + /** + * Schema generators (Optional) + * null (default) - Will be used schema generators defined in bootloaders + */ + 'generators' => null, + ], + + /** + * Prepare all internal ORM services (mappers, repositories, typecasters...) + */ + 'warmup' => \env('RR_MODE') !== null, +]; diff --git a/frameworks/PHP/spiral/app/src/App.php b/frameworks/PHP/spiral/app/src/App.php index b40bd257aa5..ffd8ebdf8ab 100644 --- a/frameworks/PHP/spiral/app/src/App.php +++ b/frameworks/PHP/spiral/app/src/App.php @@ -31,14 +31,7 @@ class App extends Kernel */ protected const LOAD = [ // Core Services - Bootloader\DebugBootloader::class, Bootloader\SnapshotsBootloader::class, - - // Security and validation - Bootloader\Security\EncrypterBootloader::class, - Bootloader\Security\FiltersBootloader::class, - Bootloader\Security\GuardBootloader::class, - RoadRunnerBridge\HttpBootloader::class, // HTTP extensions @@ -59,8 +52,6 @@ class App extends Kernel // Template engine Stempler\StemplerBootloader::class, - Scaffolder\ScaffolderBootloader::class, - // Framework commands Bootloader\CommandBootloader::class, RoadRunnerBridge\CommandBootloader::class, diff --git a/frameworks/PHP/spiral/composer.json b/frameworks/PHP/spiral/composer.json index 815b273af96..6246e74b539 100644 --- a/frameworks/PHP/spiral/composer.json +++ b/frameworks/PHP/spiral/composer.json @@ -16,14 +16,6 @@ "spiral/roadrunner-bridge": "^3.0", "spiral/roadrunner-cli": "^2.4" }, - "scripts": { - "post-create-project-cmd": [ - "php -r \"copy('.env.sample', '.env');\"", - "php app.php encrypt:key -m .env", - "php app.php configure -vv", - "rr get-binary --quiet" - ] - }, "autoload": { "psr-4": { "App\\": "app/src/" diff --git a/frameworks/PHP/spiral/spiral.dockerfile b/frameworks/PHP/spiral/spiral.dockerfile index 1f5d3440a48..22f390d0e49 100644 --- a/frameworks/PHP/spiral/spiral.dockerfile +++ b/frameworks/PHP/spiral/spiral.dockerfile @@ -1,4 +1,4 @@ -FROM php:8.3-cli +FROM php:8.4-cli RUN apt-get update -yqq > /dev/null && apt-get install -yqq git unzip > /dev/null COPY --from=composer/composer:latest-bin --link /composer /usr/local/bin/composer @@ -9,7 +9,7 @@ RUN docker-php-ext-install \ sockets > /dev/null # RoadRunner >= 2024.x.x requires protobuf extensions to be installed -ARG PROTOBUF_VERSION="4.26.1" +ARG PROTOBUF_VERSION="4.30.1" RUN pecl channel-update pecl.php.net RUN MAKEFLAGS="-j $(nproc)" pecl install protobuf-${PROTOBUF_VERSION} > /dev/null @@ -22,7 +22,7 @@ RUN composer install --optimize-autoloader --classmap-authoritative --no-dev --q # pre-configure RUN ./vendor/bin/rr get-binary > /dev/null 2>&1 -RUN php app.php configure > /dev/null 2>&1 +RUN php app.php configure EXPOSE 8080