docs: improve CLAUDE.md with Claude Code header and expanded guidance
Add required Claude Code header, Laravel 12 version, example onWebRoutes method, single test commands, package namespaces, and consolidated conventions from other AI instruction files. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
8fe508541f
commit
c3a783f547
1 changed files with 60 additions and 24 deletions
80
CLAUDE.md
80
CLAUDE.md
|
|
@ -1,8 +1,10 @@
|
||||||
# Core PHP Framework Project
|
# CLAUDE.md
|
||||||
|
|
||||||
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
Modular monolith using Core PHP Framework. Modules live in `app/Mod/{Name}/Boot.php`.
|
Modular monolith using Core PHP Framework (Laravel 12). Modules live in `app/Mod/{Name}/Boot.php` and register via events.
|
||||||
|
|
||||||
**Event-driven registration:**
|
**Event-driven registration:**
|
||||||
```php
|
```php
|
||||||
|
|
@ -13,54 +15,88 @@ class Boot
|
||||||
ApiRoutesRegistering::class => 'onApiRoutes',
|
ApiRoutesRegistering::class => 'onApiRoutes',
|
||||||
AdminPanelBooting::class => 'onAdminPanel',
|
AdminPanelBooting::class => 'onAdminPanel',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function onWebRoutes(WebRoutesRegistering $event): void
|
||||||
|
{
|
||||||
|
$event->routes(fn() => require __DIR__.'/Routes/web.php');
|
||||||
|
$event->views('blog', __DIR__.'/Views');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Module paths:** `app/Core/`, `app/Mod/`, `app/Website/` (configured in `config/core.php`)
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
composer run dev # Dev server (if configured)
|
# Development
|
||||||
php artisan serve # Laravel dev server
|
php artisan serve # Laravel dev server
|
||||||
npm run dev # Vite
|
npm run dev # Vite with HMR
|
||||||
./vendor/bin/pint --dirty # Format changed files
|
composer dev:packages # Use local packages (composer.local.json)
|
||||||
php artisan test # All tests
|
|
||||||
php artisan make:mod Blog # Create module
|
# Module creation
|
||||||
|
php artisan make:mod Blog --all # Full module (web, api, admin)
|
||||||
|
php artisan make:mod Blog --web # Web routes only
|
||||||
|
php artisan make:mod Blog --api # API routes only
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
vendor/bin/pest # Run all tests
|
||||||
|
vendor/bin/pest tests/Feature # Run feature tests only
|
||||||
|
vendor/bin/pest --filter="test name" # Run single test by name
|
||||||
|
vendor/bin/pest path/to/TestFile.php # Run single test file
|
||||||
|
|
||||||
|
# Code quality
|
||||||
|
vendor/bin/pint --dirty # Format changed files only
|
||||||
|
vendor/bin/pint # Format all files
|
||||||
```
|
```
|
||||||
|
|
||||||
## Module Structure
|
## Module Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
app/Mod/Blog/
|
app/Mod/Blog/
|
||||||
├── Boot.php # Event listeners
|
├── Boot.php # Event listeners (required)
|
||||||
├── Models/ # Eloquent models
|
├── Models/ # Eloquent models
|
||||||
├── Routes/
|
├── Routes/
|
||||||
│ ├── web.php # Web routes
|
│ ├── web.php # Web routes
|
||||||
│ └── api.php # API routes
|
│ └── api.php # API routes
|
||||||
├── Views/ # Blade templates
|
├── Views/ # Blade templates (namespaced as 'blog::')
|
||||||
├── Livewire/ # Livewire components
|
├── Livewire/ # Livewire components
|
||||||
├── Migrations/ # Database migrations
|
├── Migrations/ # Auto-discovered migrations
|
||||||
└── Tests/ # Module tests
|
└── Tests/ # Module tests
|
||||||
```
|
```
|
||||||
|
|
||||||
## Packages
|
## Packages
|
||||||
|
|
||||||
| Package | Purpose |
|
| Package | Namespace | Purpose |
|
||||||
|---------|---------|
|
|---------|-----------|---------|
|
||||||
| `host-uk/core` | Core framework, events, module discovery |
|
| `host-uk/core` | `Core\` | Framework core, events, module discovery |
|
||||||
| `host-uk/core-admin` | Admin panel, Livewire modals |
|
| `host-uk/core-admin` | `Core\Admin\` | Admin panel, Livewire modals |
|
||||||
| `host-uk/core-api` | REST API, scopes, rate limiting, webhooks |
|
| `host-uk/core-api` | `Core\Api\` | REST API, scopes, rate limiting, webhooks |
|
||||||
| `host-uk/core-mcp` | Model Context Protocol for AI agents |
|
| `host-uk/core-mcp` | `Core\Mcp\` | Model Context Protocol for AI agents |
|
||||||
|
|
||||||
## Conventions
|
## Conventions
|
||||||
|
|
||||||
- UK English (colour, organisation, centre)
|
**Language:** UK English (colour, organisation, centre, behaviour, licence/license)
|
||||||
- PSR-12 coding style (Laravel Pint)
|
|
||||||
- Pest for testing
|
**PHP:**
|
||||||
- Livewire + Flux Pro for UI
|
- `declare(strict_types=1);` in all files
|
||||||
|
- Full type hints on parameters and return types
|
||||||
|
- PSR-12 formatting (Laravel Pint)
|
||||||
|
- Pest for testing (not PHPUnit syntax)
|
||||||
|
|
||||||
|
**Naming:**
|
||||||
|
- Models: Singular PascalCase (`Post`)
|
||||||
|
- Tables: Plural snake_case (`posts`)
|
||||||
|
- Livewire Pages: `{Feature}Page`
|
||||||
|
- Livewire Modals: `{Feature}Modal`
|
||||||
|
|
||||||
|
**UI Stack:**
|
||||||
|
- Livewire 3 for reactive components
|
||||||
|
- Flux Pro for UI components (not vanilla Alpine)
|
||||||
|
- Font Awesome Pro for icons (not Heroicons)
|
||||||
|
- Tailwind CSS for styling
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
- `Core\` namespace and vendor packages: EUPL-1.2 (copyleft)
|
- `Core\` namespace and vendor packages: EUPL-1.2 (copyleft)
|
||||||
- `app/Mod/*`, `app/Website/*`: Your choice (no copyleft)
|
- `app/Mod/*`, `app/Website/*`: Your choice (no copyleft)
|
||||||
|
|
||||||
See LICENSE for full details.
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue