1. Go to this page and download the library: Download power-modules/console 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');
/* Start to develop here. Best regards https://php-download.com/ */
power-modules / console example snippets
namespace MyApp\Orders;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
#[AsCommand(name: 'orders:process', description: 'Process pending orders')]
final class ProcessOrdersCommand extends Command
{
public function __construct(
private readonly OrderService $orderService,
) {
parent::__construct();
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->orderService->processPendingOrders();
$output->writeln('Orders processed successfully!');
return Command::SUCCESS;
}
}
namespace MyApp\Orders;
use Modular\Console\Contract\ProvidesConsoleCommands;
use Modular\Framework\PowerModule\Contract\PowerModule;
use Modular\Framework\PowerModule\Contract\ConfigurableContainerInterface;
final class OrderModule implements PowerModule, ProvidesConsoleCommands
{
public function getConsoleCommands(): array
{
return [
ProcessOrdersCommand::class,
];
}
public function register(ConfigurableContainerInterface $container): void
{
$container->set(OrderService::class, OrderService::class);
$container->set(ProcessOrdersCommand::class, ProcessOrdersCommand::class)
->addArguments([OrderService::class])
;
}
}
# bin/console
declare(strict_types=1);
use Modular\Console\PowerModule\Setup\ConsoleCommandsSetup;
use Modular\Framework\App\ModularAppBuilder;
use Symfony\Component\Console\Application;
->build()
;
$app->get(Application::class)->run();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.