Search by

ebrana / mate-tools

Kamhal24

Generic Symfony AI Mate tools for eBRANA projects (dev only)

Package info

github.com/ebrana/mate-tools

pkg:composer/ebrana/mate-tools

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-12-02 13:13 UTC

This package is not auto-updated.

Last update: 2026-12-03 11:54:34 UTC


README

Generic Symfony AI Mate extension for Symfony + Doctrine + PostgreSQL projects (dev only). Gives agents compact, read-only tools instead of psql, curl, log greps and the web profiler.

PostgreSQL only: the ebr-sql tool relies on pg_read_all_data and PostgreSQL catalogs.

Install

composer require --dev ebrana/mate-tools

Mate is BETA and Composer ignores inline @beta flags of dependencies, so the consumer's root composer.json must allow it: either "minimum-stability": "beta" with "prefer-stable": true, or require symfony/ai-mate, symfony/ai-symfony-mate-extension and symfony/ai-monolog-mate-extension as ~1.0.0@beta in its own require-dev.

The package is registered in mate/extensions.php by mate discover. It runs automatically on composer install/update when symfony/ai-mate-composer-plugin is allowed, otherwise run vendor/bin/mate discover. Do not write extensions.php by hand; only the enabled / mode values are yours to change.

The monolog and symfony Mate extensions must stay enabled: ebr-log-errors needs LogReader and ebr-api-request needs ProfilerDataProvider, so disabling either breaks container compilation. ProfilerDataProvider is @internal to the Symfony extension, hence the ~1.0.0 pin.

Check the registration:

vendor/bin/mate debug:extensions
vendor/bin/mate tools:list --extension=ebrana/mate-tools

DATABASE_URL is read from the process environment. To load the project's .env, set ->set('mate.env_file', '.env') in mate/config.php.

Tools

Tool Purpose
ebr-sql one SELECT/WITH/EXPLAIN in a READ ONLY transaction as pg_read_all_data, 5 s timeout
ebr-table kind, columns, PK, indexes, FKs and estimated rows of one table or view
ebr-db-status pending migrations, mapping validity, schema diff (calls the app console)
ebr-log-errors errors from var/log grouped by normalised message
ebr-api-request GET request to the running app, with SQL summary and exception from its profiler

It also adds a compact db formatter for the profiler resource.

Parameters

Override in the project's mate/config.php.

Parameter Default Meaning
mate_tools.database ['url' => '%env(default::DATABASE_URL)%'] DBAL connection params (url DSN, host, port, user, password, dbname, charset, sslmode, application_name); driver is always pdo_pgsql
mate_tools.console bin/console console script, relative to %mate.root_dir% or absolute
mate_tools.console_memory_limit 1G memory_limit of the console child processes
mate_tools.api_base_uri '' base URI for ebr-api-request; the tool fails with a hint while empty
mate_tools.api_user null username for lexik:jwt:generate-token; null means no default auth
mate_tools.api_user_class null passed as --user-class=; null omits the option

ebr-api-request option auth=user|none defaults to user when mate_tools.api_user is set, otherwise none. auth=user is only allowed for local base URIs (localhost, 127.0.0.1, *.loc).

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $container): void {
    $container->parameters()
        ->set('mate_tools.database', [
            'host' => '%env(DATABASE_HOST)%',
            'port' => '%env(int:DATABASE_PORT)%',
            'user' => '%env(DATABASE_USER)%',
            'password' => '%env(DATABASE_PASSWORD)%',
            'dbname' => '%env(DATABASE_DB)%',
        ])
        ->set('mate_tools.api_base_uri', 'https://app.loc')
        ->set('mate_tools.api_user', 'admin')
        ->set('mate_tools.api_user_class', 'App\Entity\User');
};

Project-specific tools

Tools for one project belong in that project's mate/src/, not here. Prefix their names with the project name (e.g. shop-*): Mate keys discovered tools by name, so a duplicate name silently overwrites the other tool without any error.

Development

composer install
composer phpstan
composer cs
composer test

Database tests need MATE_TOOLS_TEST_DATABASE_URL (e.g. postgresql://postgres:postgres@localhost:5432/postgres, a role allowed to SET ROLE pg_read_all_data) and are skipped without it.