1. Go to this page and download the library: Download mb4it/bitrix-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/ */
mb4it / bitrix-console example snippets
declare(strict_types=1);
namespace Local\Console;
use MB\Bitrix\Console\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
#[AsCommand(name: 'orders:sync', description: 'Sync orders from ERP.')]
final class SyncOrdersCommand extends Command
{
protected function configure(): void
{
$this->addArgument('since', InputArgument::OPTIONAL, 'ISO date.');
}
public function isDestructive(): bool { return false; }
public function manifestMeta(): array
{
return ['examples' => ['bx orders:sync 2026-01-01 --format=json']];
}
protected function handle(): int
{
$since = (string) $this->input->getArgument('since');
$this->data('since', $since); // в машинный payload
$this->note("Syncing since {$since}"); // строка (в text-режиме печатается)
$this->textTable(['ID', 'Sum'], [[1, 100], [2, 200]]); // таблица только для человека
$this->success('Done.');
return self::SUCCESS;
}
}
bash
php vendor/bin/bx list # список команд
php vendor/bin/bx about # окружение и рантайм
php vendor/bin/bx manifest --format=json # самоописание для ИИ-агента
php vendor/bin/bx tinker # REPL
bash
php vendor/bin/bx bx:install # создаст ./bx в корне (DocumentRoot)
php bx list