🔍 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.
- Installation
- Configuration
- Usage
- Supported extractors
- Output example
- Example prompts
- Contributing
- License
- Credits
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],
];
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']
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:
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 |
{
"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.
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!
PRs welcome! To contribute:
- Fork the repository
- Create a branch
- Write tests or improve extractors
- Submit a pull request
Released under the MIT License
Developed with ❤️ by Guillaume Valadas Part of the AI Context Lab