adachsoft/symfony-console-tool

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Forks: 0

pkg:composer/adachsoft/symfony-console-tool

0.1.0 2026-02-01 21:37 UTC

This package is not auto-updated.

Last update: 2026-02-02 18:59:31 UTC


README

Library providing an AI SPI tool for running Symfony Console commands (run) and listing available commands (list) in external Symfony projects.

Installation

composer require adachsoft/symfony-console-tool

Usage with adachsoft/ai-tool-call (SPI)

Register SymfonyConsoleToolFactory in the AiToolCallFacadeBuilder and configure the tool using ConfigMap:

use AdachSoft\AiToolCall\PublicApi\Builder\AiToolCallFacadeBuilder;
use AdachSoft\AiToolCall\SPI\Collection\ConfigMap;
use AdachSoft\SymfonyConsoleTool\Tool\SymfonyConsoleToolFactory;

$builder = AiToolCallFacadeBuilder::new()
    ->withSpiFactories([
        new SymfonyConsoleToolFactory(),
    ])
    ->withToolConfigs([
        'symfony_console' => new ConfigMap([
            'base_path' => '/path/to/your/symfony/project',
            'console_path' => 'bin/console',
            'php_binary' => 'php',
            'timeout' => 30.0,
        ]),
    ]);

$facade = $builder->build();

Then you can call the symfony_console tool via the public API:

use AdachSoft\AiToolCall\PublicApi\Dto\ToolCallRequestDto;

// List commands
$listResult = $facade->callTool(new ToolCallRequestDto(
    toolName: 'symfony_console',
    parameters: [
        'action' => 'list',
    ],
));

// Run a specific command
$runResult = $facade->callTool(new ToolCallRequestDto(
    toolName: 'symfony_console',
    parameters: [
        'action' => 'run',
        'command' => 'cache:clear --env=prod',
    ],
));

The result payload is an array with the following keys:

  • exit_code (int)  command exit code
  • output (string)  STDOUT contents
  • error_output (string)  STDERR contents

Security

console_path is resolved relative to base_path using adachsoft/normalized-safe-path. Any attempt to escape base_path (path traversal) will result in an error and the tool call will fail.