Update AGENTS.md with coding standards and commands
This commit is contained in:
parent
3ff85b8143
commit
c1957baab9
38
AGENTS.md
38
AGENTS.md
@ -1,27 +1,27 @@
|
||||
# AGENT CODING STANDARDS
|
||||
|
||||
This project is a PHP MVC application using Composer, Twig, and FastRoute, running in an LXC container.
|
||||
This project is a PHP MVC application using Composer, Twig, FastRoute, and SQLite in an LXC container.
|
||||
|
||||
## 🛠️ Development Commands
|
||||
|
||||
| Type | Command | Notes |
|
||||
| :--- | :--- | :--- |
|
||||
| **Dependencies** | `incus exec www composer install` / `incus exec www composer update` | Run from the host machine. Apache2 with PHP/Composer runs in the INCUS container 'www'. The folder ./ is shared with /var/www/localhost/ in the container, and port 80 is shared with the host. Use `update` after editing `composer.json`. |
|
||||
| **Linting** | N/A | No dedicated tool. Adhere to PSR-12 standards. |
|
||||
| **Testing** | `curl localhost` | No testing framework configured. Avoid adding tests until one is introduced. |
|
||||
- **Dependencies:** `composer install` / `update` (updates after editing composer.json)
|
||||
- **Linting:** N/A (adhere to PSR-12 manually)
|
||||
- **Testing:** `curl localhost` (no framework; run manual scripts like `php test.php` for single tests)
|
||||
- **Build:** N/A (direct PHP execution)
|
||||
- **Version Control:** `git status` / `add` / `commit` / `push`
|
||||
|
||||
## 📐 Code Style & Conventions
|
||||
|
||||
1. **Architecture:** Strict MVC pattern. Logic in `src/Controllers`, data access in `src/Models`, views in `templates/`.
|
||||
2. **Namespacing:** Use `App\` as the base namespace (PSR-4).
|
||||
3. **Naming:** Classes are `PascalCase`. Functions, methods, and variables are `camelCase`.
|
||||
4. **Templating:** Use **Twig** (`.twig`). All HTML rendering must be done via Twig.
|
||||
5. **I18n:** All user-facing strings must use `App\Services\TranslationService` (PHP) or `{{ trans('ID') }}` (Twig).
|
||||
6. **Error Handling:** Use PHP's native exception handling (`try/catch`). Log critical errors with `error_log()`.
|
||||
7. **Database:** Access SQLite via `App\Database\Database::getInstance()`. **Do not** use direct `new PDO()`.
|
||||
8. **Imports:** Use fully qualified class names or `use` statements at the top of the file.
|
||||
9. **Security:** Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.
|
||||
10. **Types:** Use type hints for function parameters and return types where possible.
|
||||
11. **Formatting:** Follow PSR-12 standards for code formatting.
|
||||
12. **Comments:** Do not add comments unless explicitly requested.
|
||||
13. **Libraries:** Only use libraries already in composer.json. Check composer.json before adding new dependencies.
|
||||
1. **Architecture:** MVC pattern (Controllers in `src/Controllers/`, Models in `src/Models/`, Views in `templates/`)
|
||||
2. **Namespacing:** PSR-4 with `App\` base
|
||||
3. **Naming:** Classes `PascalCase`, methods/variables `camelCase`
|
||||
4. **Templating:** Twig only (`.twig` files)
|
||||
5. **I18n:** Use `App\Services\TranslationService` (PHP) or `{{ trans('ID') }}` (Twig)
|
||||
6. **Error Handling:** `try/catch` blocks; log with `error_log()`
|
||||
7. **Database:** Use `App\Database\Database::getInstance()` (no direct PDO)
|
||||
8. **Imports:** `use` statements at top or fully qualified names
|
||||
9. **Security:** No secrets/keys exposure or logging
|
||||
10. **Types:** Type hints on params/returns where possible
|
||||
11. **Formatting:** PSR-12
|
||||
12. **Comments:** Avoid unless requested
|
||||
13. **Libraries:** Check composer.json before adding
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user