|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +`dev-to-geek/laravel-init` is a Laravel package that bootstraps Laravel projects with preconfigured development tools (Pint, Larastan, Pest, Pail, Rector, Laravel Boost) via a single artisan command: `php artisan laravel-init:install`. |
| 8 | + |
| 9 | +- **PHP:** ^8.3 | **Laravel:** ^12.0, ^13.0 |
| 10 | +- **Namespace:** `Dev2Geek\LaravelInit` |
| 11 | +- All files must use `declare(strict_types=1)` |
| 12 | + |
| 13 | +## Commands |
| 14 | + |
| 15 | +```bash |
| 16 | +composer test # Run tests (Pest) |
| 17 | +composer test-coverage # Parallel tests with coverage |
| 18 | +composer analyse # PHPStan static analysis (level 10, 2G memory) |
| 19 | +composer format # Code formatting (Pint, Laravel preset) |
| 20 | +composer refactor # Rector automated refactoring |
| 21 | +``` |
| 22 | + |
| 23 | +Run a single test file: |
| 24 | +```bash |
| 25 | +vendor/bin/pest tests/Feature/InstallCommandTest.php |
| 26 | +``` |
| 27 | + |
| 28 | +Run a single test by name: |
| 29 | +```bash |
| 30 | +vendor/bin/pest --filter="can run laravel-init:install command" |
| 31 | +``` |
| 32 | + |
| 33 | +## Architecture |
| 34 | + |
| 35 | +The package has a minimal structure with one primary flow: |
| 36 | + |
| 37 | +**ServiceProvider** (`src/LaravelInitServiceProvider.php`) registers a single artisan command and merges config. |
| 38 | + |
| 39 | +**InstallCommand** (`src/Commands/InstallCommand.php`) is the core of the package. It sequentially installs tools via `Process::run()` composer commands, copies configuration stubs via `File::copy()`, and wraps each step in `spin()` for terminal feedback. Each step fails fast with `self::fail()` on error. The `--remove-me` flag triggers self-uninstallation. |
| 40 | + |
| 41 | +**Stubs** (`stubs/`) contain configuration templates (pint.json, phpstan.neon.dist, rector.php) that get copied to the target project root during installation. |
| 42 | + |
| 43 | +## Testing |
| 44 | + |
| 45 | +Tests use **Pest** with **Orchestra Testbench**. The base `TestCase` (`tests/TestCase.php`) extends `Orchestra\Testbench\TestCase` and registers the package's service provider. |
| 46 | + |
| 47 | +Testing patterns used throughout: |
| 48 | +- `Process::fake()` with pattern matching to mock composer commands |
| 49 | +- `File::spy()` / `File::shouldReceive()` for filesystem mocking |
| 50 | +- `$this->artisan('laravel-init:install')` for command integration tests |
| 51 | +- Arrange/Act/Assert structure in every test |
| 52 | + |
| 53 | +Architecture tests (`tests/ArchTest.php`) enforce no debug functions (`dd`, `dump`, `ray`). |
| 54 | + |
| 55 | +## Code Quality Standards |
| 56 | + |
| 57 | +- **PHPStan level 10** (maximum) with Larastan — analyzes `src/` only |
| 58 | +- **Pint** with Laravel preset plus strict rules: `strict_comparison`, `declare_strict_types`, `ordered_class_elements`, `protected_to_private` |
| 59 | +- **Rector** runs on `src/`, `config/`, `tests/` with sets: deadCode, codeQuality, typeDeclarations, privatization, earlyReturn, strictBooleans |
| 60 | +- Class element ordering: traits → constants → properties → constructor → magic → static methods → public → protected → private |
0 commit comments