for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Micro framework package.
*
* (c) Stanislau Komar <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Micro\Plugin\Console\Business\Factory;
use Micro\Component\DependencyInjection\Autowire\AutowireHelperInterface;
use Micro\Plugin\Locator\Facade\LocatorFacadeInterface;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
class ConsoleApplicationFactory implements ConsoleApplicationFactoryInterface
{
public function __construct(
private readonly LocatorFacadeInterface $locatorFacade,
private readonly AutowireHelperInterface $autowireHelper
) {
}
public function create(): Application
$application = new Application();
$application->setAutoExit(false);
// $application->setCatchExceptions(true);
$this->registerCommands($application);
return $application;
protected function registerCommands(Application $application): void
foreach ($this->locatorFacade->lookup(Command::class) as $command) {
$cmdCallback = $this->autowireHelper->autowire($command);
$application->add($cmdCallback());