|
| 1 | +# Agents Guide for Sons of PHP Monorepo |
| 2 | + |
| 3 | +This repository is a PHP monorepo containing many packages under `src/`. This guide provides consistent instructions for AI coding agents to work safely and effectively across the codebase. |
| 4 | + |
| 5 | +## Repo Layout |
| 6 | + |
| 7 | +- Root: build tooling (`Makefile`, composer), shared configs, CI inputs. |
| 8 | +- Code: packages live under `src/SonsOfPHP/*`, typically with `src/` and `Tests/` subfolders. |
| 9 | +- Docs: developer documentation in `docs/` with a GitBook-style `SUMMARY.md`. |
| 10 | +- Tools: development tools vendored under `tools/` (phpunit, psalm, rector, php-cs-fixer, etc.). |
| 11 | + |
| 12 | +## Ground Rules |
| 13 | + |
| 14 | +- Prefer minimal, targeted changes; avoid refactors beyond the task scope. |
| 15 | +- Never edit anything under any `vendor/` directory or generated artifacts like `dist/`. |
| 16 | +- Maintain backward compatibility for public APIs unless explicitly instructed otherwise. |
| 17 | +- Update relevant docs under `docs/` when behavior or public APIs change. |
| 18 | +- Keep code style consistent; use provided tooling to format, lint, and check types. |
| 19 | + |
| 20 | +## Setup |
| 21 | + |
| 22 | +- Install dependencies once at the repo root: |
| 23 | + - `make install` |
| 24 | + |
| 25 | +## Common Tasks |
| 26 | + |
| 27 | +- Run tests (entire repo): |
| 28 | + - `make test` |
| 29 | +- Run tests (limit to a package): |
| 30 | + - `PHPUNIT_OPTIONS='path/to/package/Tests' make test` |
| 31 | +- Code style (dry-run): |
| 32 | + - `make php-cs-fixer` |
| 33 | +- Static analysis (Psalm): |
| 34 | + - `make psalm` |
| 35 | +- Rector & style upgrades (may modify files): |
| 36 | + - `make upgrade-code` |
| 37 | +- Lint PHP syntax: |
| 38 | + - `make lint` |
| 39 | +- Coverage report: |
| 40 | + - `make coverage` |
| 41 | + |
| 42 | +## When Editing a Package |
| 43 | + |
| 44 | +- Work inside that package directory (e.g. `src/SonsOfPHP/Component/Clock`). |
| 45 | +- Put new source under that package’s `src/`; add tests under its `Tests/`. |
| 46 | +- Use the package-focused test command above to tighten feedback cycles. |
| 47 | + |
| 48 | +## Documentation |
| 49 | + |
| 50 | +- Update `docs/` to reflect user-facing changes. |
| 51 | +- Add or modify the most relevant page (e.g., `docs/components/*.md`, `docs/contracts/*.md`, or `docs/symfony-bundles/*.md`). |
| 52 | +- If adding a new page, ensure it’s listed in `docs/SUMMARY.md`. |
| 53 | + |
| 54 | +## Pull Request Checklist |
| 55 | + |
| 56 | +- Build passes: `make test` (optionally with coverage). |
| 57 | +- Code quality passes: `make php-cs-fixer`, `make psalm`, and (if applicable) `make upgrade-code`. |
| 58 | +- Docs updated where needed. |
| 59 | +- No changes to `vendor/` or generated artifacts. |
| 60 | + |
0 commit comments