2026-01-28 14:13:44 +00:00
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
2026-03-13 13:38:02 +00:00
**core-developer** (`lthn/php-developer` ) — developer tools module for the Core PHP Framework. Provides an admin panel for debugging and monitoring: log viewer, route inspector, database explorer, cache management, activity log, and SSH server connections.
2026-01-28 14:13:44 +00:00
- PHP 8.2+ / Laravel 11-12 / Livewire 3-4
2026-03-13 13:38:02 +00:00
- Module namespace: `Core\Developer\`
- Dependencies: `lthn/php` (core framework), `core/php-admin` (admin panel)
- All features gated behind "Hades" (god-mode) authorization
2026-01-28 14:13:44 +00:00
2026-03-13 13:38:02 +00:00
## Commands
2026-01-28 14:13:44 +00:00
```bash
2026-03-13 13:38:02 +00:00
# Tests
2026-03-17 09:08:38 +00:00
composer test # All tests
composer test -- --testsuite=Unit # Unit only
composer test -- --testsuite=Feature # Feature only
composer test -- --filter="test name" # Single test
# Code style (PSR-12 via Laravel Pint)
composer lint # Fix code style
./vendor/bin/pint --dirty # Format changed files only
2026-01-28 14:13:44 +00:00
2026-03-13 13:38:02 +00:00
# Frontend
2026-01-28 14:13:44 +00:00
npm run dev # Vite dev server
npm run build # Production build
```
## Architecture
2026-03-13 13:38:02 +00:00
### Event-Driven Lazy Loading
2026-01-28 14:13:44 +00:00
2026-03-13 13:38:02 +00:00
The module registers via `Boot` (a `ServiceProvider` + `AdminMenuProvider` ). Nothing loads until events fire:
2026-01-28 14:13:44 +00:00
```php
public static array $listens = [
2026-03-13 13:38:02 +00:00
AdminPanelBooting::class => 'onAdminPanel', // loads routes, views
ConsoleBooting::class => 'onConsole', // registers artisan commands
2026-01-28 14:13:44 +00:00
];
```
2026-03-13 13:38:02 +00:00
`boot()` always runs (translations, config merge, admin menu registration, rate limiters, query logging in local env).
2026-01-28 14:13:44 +00:00
2026-03-13 13:38:02 +00:00
### Routing
2026-01-28 14:13:44 +00:00
2026-03-13 13:38:02 +00:00
All routes defined in `src/Routes/admin.php` , loaded only when `AdminPanelBooting` fires:
2026-01-28 14:13:44 +00:00
2026-03-13 13:38:02 +00:00
- **Admin pages:** `/hub/dev/*` — Livewire components, route names `hub.dev.*`
- **API endpoints:** `/hub/api/dev/*` — JSON controller actions, route names `hub.api.dev.*` , each with throttle middleware
2026-01-28 14:13:44 +00:00
2026-03-13 13:38:02 +00:00
Both groups use `RequireHades` middleware. Rate limiters (`dev-cache-clear` , `dev-logs` , `dev-routes` , `dev-session` ) are configured in `Boot::configureRateLimiting()` .
2026-01-28 14:13:44 +00:00
2026-03-13 13:38:02 +00:00
### Livewire Components
2026-01-28 14:13:44 +00:00
2026-03-13 13:38:02 +00:00
Located at `src/View/Modal/Admin/` . Use attribute-based syntax:
2026-01-28 14:13:44 +00:00
```php
#[Title('Application Logs')]
#[Layout('hub::admin.layouts.app')]
class Logs extends Component
```
2026-03-13 13:38:02 +00:00
Each component calls `$this->checkHadesAccess()` in `mount()` (private method that aborts 403). Views referenced as `developer::admin.{name}` , files in `src/View/Blade/admin/` .
2026-01-28 14:13:44 +00:00
2026-03-13 13:38:02 +00:00
### Authorization: Hades
2026-01-28 14:13:44 +00:00
2026-03-13 13:38:02 +00:00
Two enforcement layers:
1. `RequireHades` middleware on all route groups — checks `$user->isHades()`
2. `checkHadesAccess()` in each Livewire component's `mount()` — redundant guard
2026-01-28 14:13:44 +00:00
2026-03-13 13:38:02 +00:00
### SSH / Remote Server Management
2026-01-28 14:13:44 +00:00
2026-03-13 13:38:02 +00:00
`RemoteServerManager` trait (in `src/Concerns/` ) provides SSH operations via phpseclib3. The `Server` model stores connection details with `private_key` encrypted via Laravel's `encrypted` cast. Key pattern:
2026-01-28 14:13:44 +00:00
```php
2026-03-13 13:38:02 +00:00
$this->withConnection($server, function () {
$this->run('git pull');
2026-01-28 14:13:44 +00:00
});
```
2026-03-13 13:38:02 +00:00
The trait verifies workspace ownership before connecting.
### Multi-Tenancy
2026-01-28 14:13:44 +00:00
2026-03-13 13:38:02 +00:00
The `Server` model uses `BelongsToWorkspace` trait for workspace isolation, plus `LogsActivity` (Spatie) and `SoftDeletes` .
2026-01-28 14:13:44 +00:00
2026-03-13 13:38:02 +00:00
### Localization
All UI strings in `src/Lang/en_GB/developer.php` . Key structure: `developer::developer.{section}.{key}` .
## Testing
Tests use Pest-style syntax. Use-case acceptance tests live in `src/Tests/UseCase/` . Standard PHPUnit test directories: `tests/Unit/` and `tests/Feature/` .
PHPUnit configured with SQLite `:memory:` , Telescope/Pulse disabled (`phpunit.xml` ).
## Key Conventions
- All PHP files use `declare(strict_types=1)`
- Controller extends `Core\Front\Controller` (not Laravel's base)
- Services injected via constructor (`DevController` ) or resolved from container (`app(LogReaderService::class)` )
- `LogReaderService` auto-redacts sensitive data (API keys, tokens, credentials) in log output
- Config lives in `src/config.php` , merged as `developer.*` — SSH timeouts, Hades token, Horizon notification settings
- Module also overrides Pulse vendor views: `view()->addNamespace('pulse', ...)`