friendsofmago / mago-symfony
Symfony support for the Mago static analyzer.
v0.1.0
2026-12-03 14:03 UTC
Requires
- php: ^8.1
- composer-runtime-api: ^2.0
- ext-tokenizer: *
- carthage-software/mago: ^1.60.2
Requires (Dev)
- symfony/config: ^6.4 || ^7.0
- symfony/console: ^6.4 || ^7.0
- symfony/dependency-injection: ^6.4 || ^7.0
- symfony/event-dispatcher: ^6.4 || ^7.0
- symfony/form: ^6.4 || ^7.0
- symfony/framework-bundle: ^6.4 || ^7.0
- symfony/http-foundation: ^6.4 || ^7.0
- symfony/messenger: ^6.4 || ^7.0
- symfony/routing: ^6.4 || ^7.0
- symfony/security-bundle: ^6.4 || ^7.0
- symfony/security-core: ^6.4 || ^7.0
- symfony/serializer: ^6.4 || ^7.0
- symfony/validator: ^6.4 || ^7.0
Suggests
- ext-dom: Required to load compiled Symfony XML container dumps.
- ext-libxml: Required to load compiled Symfony XML container dumps.
- ext-xmlreader: Required to load compiled Symfony XML container dumps.
Provides
None
Conflicts
None
Replaces
- alfredbez/mago-symfony: v0.1.0
README
Symfony static analysis extension for Mago. It resolves types and reports Symfony-specific mistakes across the container, config builders, console commands, lifecycle hooks, and HTTP, Form, Serializer, Messenger, and Security APIs.
Documentation: https://friendsofmago.github.io/mago-symfony/
Installation
Requires PHP 8.1 or newer with ext-tokenizer, Mago ^1.60.2, and Symfony ^6.4 || ^7.0. Compiled XML container dumps also require ext-dom, ext-libxml, and ext-xmlreader.
composer require --dev friendsofmago/mago-symfony
Register the worker in mago.toml:
[source] includes = ["vendor/symfony", "vendor/psr"] [extension-hosts.symfony] command = ["php", "-d", "xdebug.mode=off", "-d", "pcov.enabled=0", "-d", "memory_limit=512M", "vendor/friendsofmago/mago-symfony/resources/worker.php"] workers = 1 # Optional. Configure container dumps, strict service checks, or a Security user class. # environment = { # MAGO_SYMFONY_CONTAINER_XML = "var/cache/dev/App_KernelDevDebugContainer.xml", # MAGO_SYMFONY_USER_CLASS = "App\\Entity\\User", # MAGO_SYMFONY_STRICT_CONTAINER_SERVICES = "1", # }
Validate the worker and run the analyzer:
vendor/bin/mago extension validate vendor/bin/mago analyze
Documentation
- Install covers prerequisites,
[source] includes, and custom vendor layouts. - Configuration documents environment variables, container XML and JSON resolution order, diagnostic suppression, and SemVer policy.
- The worker explains worker entry points, PHP flags, and stream handling.
- Composing extensions shows how to combine
SymfonyExtension::create()orSymfonyExtension::plugins()with other Mago extensions in one worker. - Container, Console, Config TreeBuilder, HTTP, Form, Serializer, and Security, and Lifecycle and entry points cover every provider and hook.
- Diagnostics lists all six diagnostic codes, their defaults, and suppression syntax.
- Development and Limitations cover local checks, corpus runs, and design boundaries.
License
MIT. See LICENSE.