<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
robertwesner / simple-mvc-php-spawner-bundle example snippets
use RobertWesner\SimpleMvcPhp\Configuration;
use RobertWesner\SimpleMvcPhpSpawnerBundle\SpawnerBundle;
use RobertWesner\SimpleMvcPhpSpawnerBundle\SpawnerBundleConfiguration;
Configuration::BUNDLES
::load(
SpawnerBundle::class,
// optional, can be omitted
new SpawnerBundleConfiguration(
preExecuteScriptPath: __BASE_DIR__ . '/pre-command.php',
),
);
final readonly class MySpawnConfiguration implements SpawnConfigurationInterface
{
public function __construct(
private string $foo,
private string $bar,
) {}
public function __serialize(): array
{
return [
'foo' => $this->foo,
'bar' => $this->bar,
];
}
public function __unserialize(array $data): void
{
$this->foo = $data['foo'];
$this->bar = $data['bar'];
}
public function getFoo(): string
{
return $this->foo;
}
public function getBar(): string
{
return $this->bar;
}
}
class MySpawn implements SpawnInterface
{
public function run(SpawnConfigurationInterface|MySpawnConfiguration $configuration): void
{
// asynchronous task with $configuration->getFoo(), etc...
}
}
// spawner accessed through dependency injection
$this->spawner->spawn(
EchoSpawn::class,
new EchoSpawnConfiguration(
'Some value',
'Another value',
),
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.