ai-context / symfony-ai-context-bundle
Symfony bundle to generate AI-readable project context.
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=8.2
- symfony/finder: ^6.0 || ^7.0
- symfony/framework-bundle: ^6.0 || ^7.0
Requires (Dev)
- doctrine/doctrine-bundle: ^2.14
- doctrine/orm: ^3.3
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^10.0
- symfony/form: ^6.0 || ^7.0
- symfony/yaml: ^7.3
README
🔍 Automatically generate a structured, AI-ready JSON context from your Symfony application — including entities, services, controllers, routes, repositories, and more. Perfect for feeding to LLMs like GPT for code understanding, generation, or assistance.
Table of Contents
- Installation
- Configuration
- Usage
- Supported extractors
- Output example
- Example prompts
- Contributing
- License
- Credits
Installation
composer require ai-context/symfony-ai-context-bundle --dev
Make sure the bundle is enabled (Symfony Flex should do this automatically):
// config/bundles.php return [ AiContextBundle\AiContextBundle::class => ['dev' => true, 'test' => true], ];
Configuration
Configure the bundle in config/packages/ai_context.yaml
you can edit the default values:
ai_context: output_dir: '%kernel.project_dir%/var/ai_context' output_filename: 'ai-context.json' output_dir_checksum: '%kernel.project_dir%/var/ai-context/ai-context-checksum.json' include: routes: true entities: true services: true controllers: true repositories: true events: true forms: true paths: entities: ['%kernel.project_dir%/src/Entity'] services: ['%kernel.project_dir%/src/Service'] controllers: ['%kernel.project_dir%/src/Controller'] repositories: ['%kernel.project_dir%/src/Repository'] events: ['%kernel.project_dir%/src/Event'] forms: ['%kernel.project_dir%/src/Form']
Usage
Generate the AI context:
php bin/console ai-context:generate
The command outputs a structured JSON file (by default in var/ai_context/ai-context.json) including:
Supported extractors
Feature | Description |
---|---|
Entities | Doctrine field types and associations |
Services | Public methods with full type signatures |
Controllers | Public actions and routes |
Routes | Names, methods, paths, controllers |
Repositories | Public custom methods |
Events | Event class names and dispatching metadata |
Forms | Field names, types and options |
Output example
{ "entities": [ { "entity": "App\\Entity\\Article", "fields": { "id": "integer", "name": "string", "createdAt": "datetime_immutable", "updatedAt": "datetime_immutable" }, "associations": { "category": "ManyToOne => App\\Entity\\Category", "inventories": "OneToMany => App\\Entity\\Inventory" } } ], "controllers": [ { "class": "App\\Controller\\ArticleController", "short": "ArticleController", "methods": [ { "name": "new", "parameters": [ "$request: Symfony\\Component\\HttpFoundation\\Request", "$entityManager: Doctrine\\ORM\\EntityManagerInterface" ], "route": { "path": "/article/new", "methods": ["POST", "GET"], "name": "app_article_new" } } ] } ], "routes": [ { "name": "app_article_new", "path": "/article/new", "methods": ["POST", "GET"], "controller": "App\\Controller\\ArticleController::new", "defaults": {}, "requirements": {} } ], "services": [ { "class": "App\\Service\\StockManagerService", "short": "StockManagerService", "methods": [ { "name": "processStock", "parameters": [ {"name": "articleName", "type": "string"}, {"name": "quantity", "type": "int"}, {"name": "action", "type": "string"}, {"name": "categoryName", "type": "?string"}, {"name": "user", "type": "?App\\Entity\\User"} ], "returnType": "void" } ] } ] }
Perfect to feed into LLMs like GPT for project understanding.
Then you can use the AI context in your preferred LLMs or AI tools to enhance your Symfony development experience.
Example prompts
Can you give me a list of all the routes in my Symfony application?
Generate a readme file with install process.
List all services available with a quick description of each one.
Give me full details of how work the <name service> service.
Whatever you need, the AI context is here to help you!
Contributing
PRs welcome! To contribute:
- Fork the repository
- Create a branch
- Write tests or improve extractors
- Submit a pull request
License
Released under the MIT License
Credits
Developed with ❤️ by Guillaume Valadas Part of the AI Context Lab