Skip to content

Instantly share code, notes, and snippets.

@ghostwriter
Last active November 23, 2025 19:18
Show Gist options
  • Select an option

  • Save ghostwriter/215a2ca3c6d1b448185ce876385b1bb0 to your computer and use it in GitHub Desktop.

Select an option

Save ghostwriter/215a2ca3c6d1b448185ce876385b1bb0 to your computer and use it in GitHub Desktop.
Configuration Extension for ghostwriter/container
{
"extra": {
"ghostwriter": {
"container": {
"definition": "Ghostwriter\\Wip\\Container\\WipDefinition"
}
}
},
}
<?php
declare(strict_types=1);
namespace Ghostwriter\Wip\Container\Ghostwriter\Config;
use Ghostwriter\Config\Configuration;
use Ghostwriter\Config\Interface\ConfigurationInterface;
use Ghostwriter\Container\Interface\ContainerInterface;
use Ghostwriter\Container\Interface\Service\ExtensionInterface;
use Override;
use Throwable;
use const DIRECTORY_SEPARATOR;
use function dirname;
use function implode;
/**
* @see ConfigurationExtensionTest
*
* @implements ExtensionInterface<ConfigurationInterface>
*/
final readonly class ConfigurationExtension implements ExtensionInterface
{
/**
* @param ConfigurationInterface $service
*
* @throws Throwable
*/
#[Override]
public function __invoke(ContainerInterface $container, object $service): void
{
$configuration = Configuration::new();
$configuration->mergeDirectory(implode(DIRECTORY_SEPARATOR, [dirname(__DIR__, 4), 'config']));
$service->set(self::class, $configuration->toArray());
}
}
<?php
declare(strict_types=1);
use Symfony\Component\Console\Command\Command;
/**
* @return array{
* name: string,
* package: string,
* auto_exit: bool,
* single_command: bool,
* default_command: string,
* catch_errors: bool,
* catch_exceptions: bool,
* commands: class-string<Command>
* }
*/
return [
'name' => 'wip',
'package' => 'ghostwriter/wip',
'auto_exit' => false,
'single_command' => false,
'default_command' => 'list',
'catch_errors' => true,
'catch_exceptions' => true,
'commands' => [],
];
<?php
declare(strict_types=1);
use Ghostwriter\Container\Interface\Service\DefinitionInterface;
use Ghostwriter\Container\Interface\Service\ExtensionInterface;
use Ghostwriter\Container\Interface\Service\FactoryInterface;
/**
* @return array{
* 'alias': array<class-string,class-string>,
* 'define': array<class-string,class-string<DefinitionInterface>>,
* 'extend': array<class-string,list<class-string<ExtensionInterface>>>,
* 'factory': array<class-string,class-string<FactoryInterface>>
* }
*/
return [
'alias' => [],
'define' => [],
'extend' => [],
'factory' => [],
];
<?php
declare(strict_types=1);
/**
* @return array{
* 'listen': array<'object'|class-string,list<class-string>>
* }
*/
return [
'listen' => [
'object' => [],
// Event::class => [Listener::class],
],
];
@ghostwriter
Copy link
Author

ghostwriter make:extension Application
ghostwriter make:extension Configuration
ghostwriter make:extension ListenerProvider

ghostwriter make:config ghostwriter/console
ghostwriter make:config ghostwriter/container
ghostwriter make:config ghostwriter/event-dispatcher

ghostwriter make:definition Package

ghostwriter make:event Event
ghostwriter make:factory Service
ghostwriter make:listener Listener
ghostwriter make:command RunCommand

ghostwriter ecs:init
ghostwriter rector:init

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment