A Laravel Artisan command that scans your project and generates a comprehensive, AI-friendly JSON map. This map allows AI models to understand your project's architecture, overcoming context limits and enabling more intelligent, context-aware assistance.
This package extracts and maps the following information into a single JSON file:
- Project Overview: App name, Laravel, and PHP versions.
- Environment Details: Key configuration values like environment, debug mode, and drivers for cache, queue, and session.
- Database Schema: A list of all tables along with their columns, indexes, and foreign keys, with a resilient connection mechanism.
- Model Structure: Extracts all Eloquent models, including properties (
$fillable
,$casts
, etc.) and their defined Eloquent relationships. - Route List: All web and API routes, including methods, URIs, and middleware.
- Scheduled Commands: A list of all cron jobs defined in your Console Kernel.
- Event Listeners: A map of all registered events and their corresponding listeners.
- Composer Dependencies: A list of packages used in the project.
- FilamentPHP Structure (if detected): Automatically discovers panels, resources, pages, and widgets.
You can install the package via Composer:
composer require araminco/laravel-ai-mapper
To generate the project map, run the following Artisan command:
php artisan ai:map
This will create a file named ai-project-map.json
in your project's root directory.
You can control the size and content of the map using the following options.
Use the --compact
flag to generate a summarized version that is significantly smaller. This mode simplifies verbose sections like the database schema and routes.
php artisan ai:map --compact
You can also completely exclude sections from the map:
--no-db
: Excludes the database schema.--no-files
: Excludes the directory structure.--no-models
: Excludes the model analysis.--no-routes
: Excludes the route list.--no-deps
: Excludes composer dependencies.--no-filament
: Excludes the Filament structure.--no-env
: Excludes environment details.--no-schedule
: Excludes scheduled commands.--no-events
: Excludes event listeners.
The generated JSON file will have a structure similar to this:
{
"projectName": "My Laravel App",
"laravelVersion": "12.0.0",
"environment": {
"environment": "local",
"debug_mode": true,
"cache_driver": "file",
"queue_connection": "sync",
"session_driver": "file"
},
"databaseSchema": { "...": "..." },
"models": [
{
"class": "App\\Models\\User",
"table": "users",
"relationships": { "...": "..." }
}
],
"routes": [ "...": "..." ],
"scheduledCommands": [
"$schedule->command('inspire')->hourly();"
],
"eventListeners": {
"Illuminate\\Auth\\Events\\Registered": [
"Illuminate\\Auth\\Listeners\\SendEmailVerificationNotification"
]
},
"filament": { "...": "..." }
}
Contributions are welcome! Please feel free to submit a Pull Request.
This package is open-sourced software licensed under the MIT license.