PHP code example of antidot-fw / cli
1. Go to this page and download the library: Download antidot-fw/cli library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once ('vendor/autoload.php' );
antidot-fw / cli example snippets
declare (strict_types=1 );
use Antidot \Cli \Application \Console ;
set_time_limit(0 );
call_user_func(static function () : void {
use Aura \Di \ContainerBuilder ;
use Antidot \Aura \Container \Config \ContainerConfig ;
$config = [ 'dependencies' => [], 'console' => [ 'commands' => [] ] ];
$builder = new ContainerBuilder();
return $builder->newConfiguredInstance([
new ContainerConfig(\is_array($config) ? $config : []),
], $builder::AUTO_RESOLVE);
declare (strict_types=1 );
use Antidot \Cli \Application \Console ;
set_time_limit(0 );
call_user_func(static function () : void {
declare (strict_types=1 );
namespace App \Console \Command ;
use Symfony \Component \Console \Command \Command ;
use Symfony \Component \Console \Input \InputInterface ;
use Symfony \Component \Console \Output \OutputInterface ;
use SomeDependency ;
class SomeCommand extends Command
{
private $dependency;
public function __construct (SomeDependency $dependency) {
$this ->dependency = $dependency;
parent ::__construct();
}
protected function configure () : void
{
$this ->setName('some:command:name' );
}
protected function execute (InputInterface $input, OutputInterface $output) : void
{
$output->writeLn('Hello World!!!' );
}
}
$config = [
'config_cache_path' => 'var/cache/config-cache.php' ,
'dependencies' => [
'invokables' => [
SomeCommandClass::class => SomeCommandClass::class,
SomeHelperSet::class => SomeHelperSet::class,
]
],
'console' => [
'commands' => [
'some:command:name' => SomeCommandClass::class
],
'helper-sets' => [
SomeHelperSet::class
]
]
];