ai-context/symfony-ai-context-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ai-context/symfony-ai-context-bundle

最新稳定版本:v0.5.7

Composer 安装命令:

composer require ai-context/symfony-ai-context-bundle

包简介

Symfony bundle to generate AI-readable project context.

README 文档

README

Latest Version on Packagist Total Downloads Tests PHPStan

🔍 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

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

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 15
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 15
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-04