|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Package Overview |
| 6 | + |
| 7 | +Tool Kit for Laravel is a utility package providing helpers, Blade directives, components, and enums for Laravel applications. It requires PHP 8.4+ and Laravel 12.x. |
| 8 | + |
| 9 | +**Namespace:** `Axn\ToolKit\` |
| 10 | + |
| 11 | +## Development Commands |
| 12 | + |
| 13 | +### Code Style & Quality |
| 14 | + |
| 15 | +```bash |
| 16 | +# Format code with Laravel Pint (PSR-12 + Laravel conventions) |
| 17 | +./vendor/bin/pint |
| 18 | + |
| 19 | +# Preview formatting changes without applying |
| 20 | +./vendor/bin/pint --test |
| 21 | + |
| 22 | +# Run Rector for automated refactoring and PHP modernization |
| 23 | +./vendor/bin/rector |
| 24 | + |
| 25 | +# Preview Rector changes without applying |
| 26 | +./vendor/bin/rector --dry-run |
| 27 | +``` |
| 28 | + |
| 29 | +### No Test Suite |
| 30 | + |
| 31 | +This package currently has no automated tests. Manual testing should be performed in a Laravel application that requires this package. |
| 32 | + |
| 33 | +## Architecture |
| 34 | + |
| 35 | +### File Structure |
| 36 | + |
| 37 | +- `src/helpers.php` - Global helper functions (auto-loaded via Composer) |
| 38 | +- `src/ServiceProvider.php` - Registers Blade directives, components, and views |
| 39 | +- `src/Enums/` - `AppEnv` (environment standardization) and `Civilities` (form titles) |
| 40 | +- `src/MimeTypeToFontAwesomeIcon.php` - Static MIME type to FontAwesome icon mappings (FA5, FA6, FA7) |
| 41 | +- `src/VersionNumber.php` - Semantic version to numeric ID conversion |
| 42 | +- `src/Components/RequiredFieldMarker.php` - Blade component for form required indicators |
| 43 | +- `resources/views/components/` - Blade view templates |
| 44 | + |
| 45 | +### Key Patterns |
| 46 | + |
| 47 | +**Helper Functions:** All helpers in `src/helpers.php` are globally available. Each function is wrapped in `if (!function_exists(...))` to allow application overrides. |
| 48 | + |
| 49 | +**Enums:** The `AppEnv` enum normalizes various environment name variations (e.g., "pre-prod", "preproduction" → `preprod`). Use `app_env_enum()` or `app_env_name()` helpers. |
| 50 | + |
| 51 | +**MIME Type Mapping:** The `MimeTypeToFontAwesomeIcon` class contains static arrays mapping MIME types to FontAwesome classes. FA7 has the most granular mappings (format-specific icons like `fa-file-png`, `fa-file-mp3`). |
| 52 | + |
| 53 | +### Code Style Conventions |
| 54 | + |
| 55 | +Based on `pint.json` configuration: |
| 56 | +- Laravel preset (PSR-12 base) |
| 57 | +- Native function calls must use backslash prefix in namespaced code (`\array_map`, `\count`) |
| 58 | +- Blank lines required before control flow statements (`if`, `return`, `throw`, etc.) |
| 59 | +- Named classes require parentheses on `new`, anonymous classes do not |
| 60 | + |
| 61 | +### Rector Rules |
| 62 | + |
| 63 | +The package uses aggressive modernization via Rector: |
| 64 | +- All PHP 8.4 features enabled |
| 65 | +- Dead code removal, strict booleans, early returns |
| 66 | +- Laravel-specific: Eloquent type hints, nullsafe operators, validation array syntax |
| 67 | +- Skipped: `FirstClassCallableRector` (preserves `array_map('intval', ...)` style) |
| 68 | + |
| 69 | +## Dependencies |
| 70 | + |
| 71 | +- `composer/semver` - For parsing semantic versions in `semver_to_id()` |
| 72 | +- `forxer/generic-term-translations-for-laravel` - Provides translated terms for localization features |
| 73 | + |
| 74 | +## Internationalization |
| 75 | + |
| 76 | +Number formatting helpers (`number_formatted()`, `human_readable_bytes_size()`) use the current application locale for decimal/thousands separators. Ensure Laravel's locale is properly configured. |
0 commit comments