|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Module Organization |
| 4 | +- `src/` holds the library source (primary entry: `src/Model/Model.php`) under the `Freshsauce\\` namespace. |
| 5 | +- `tests/` contains PHPUnit tests (e.g., `tests/Model/CategoryTest.php`). |
| 6 | +- `test-src/` provides example models used by tests (`App\\` namespace). |
| 7 | +- Root config files: `composer.json`, `phpunit.xml.dist`, and `docker-compose.yml`. |
| 8 | + |
| 9 | +## Build, Test, and Development Commands |
| 10 | +- `composer install` installs dependencies (PHP >= 8.3, `ext-pdo`, PHPUnit 10). |
| 11 | +- `vendor/bin/phpunit -c phpunit.xml.dist` runs the test suite. |
| 12 | +- `vendor/bin/phpstan analyse -c phpstan.neon` runs static analysis. |
| 13 | +- `vendor/bin/php-cs-fixer fix` formats the codebase (use `--dry-run --diff` in CI). |
| 14 | +- `docker-compose up -d` starts local MariaDB and PostgreSQL instances (ports 3306 and 5432). |
| 15 | + |
| 16 | +## Coding Style & Naming Conventions |
| 17 | +- PHP code uses 4-space indentation and namespaces. |
| 18 | +- Class names are `StudlyCaps` (e.g., `Model`, `CategoryTest`); methods are `camelCase`. |
| 19 | +- Table config is set via static properties like `static protected $_tableName`. |
| 20 | +- Follow PSR-4 autoloading (`Freshsauce\\` -> `src/`, `App\\` -> `test-src/`). |
| 21 | + |
| 22 | +## Testing Guidelines |
| 23 | +- PHPUnit 10 is the test runner; tests live in `tests/`. |
| 24 | +- Test classes are named `*Test` and extend `PHPUnit\Framework\TestCase`. |
| 25 | +- Tests can run against MySQL/MariaDB or PostgreSQL; configure via env vars: |
| 26 | + - `MODEL_ORM_TEST_DSN` (e.g., `mysql:host=127.0.0.1;port=3306` or `pgsql:host=127.0.0.1;port=5432;dbname=categorytest`) |
| 27 | + - `MODEL_ORM_TEST_USER`, `MODEL_ORM_TEST_PASS` |
| 28 | +- MySQL tests create/drop `categorytest`; PostgreSQL tests create/drop the `categories` table. |
| 29 | + |
| 30 | +## Commit & Pull Request Guidelines |
| 31 | +- Commit messages in this repo are short, descriptive sentences (e.g., “Fix test”, “Scrutinizer adjustments”). |
| 32 | +- Prefer imperative or present-tense summaries without a required prefix. |
| 33 | +- PRs should include a concise description, testing notes (`vendor/bin/phpunit -c phpunit.xml.dist`), and any DB/setup changes. |
| 34 | + |
| 35 | +## Configuration & Local Setup Tips |
| 36 | +- Default test connection assumes MySQL on `127.0.0.1:3306` with `root`/empty password. |
| 37 | +- For PostgreSQL, use the Docker defaults (`postgres`/`postgres`) and `dbname=categorytest`. |
| 38 | +- Ensure ports `3306` and/or `5432` are free and reachable from PHP. |
0 commit comments