2.6 KiB
2.6 KiB
Repository Guidelines
Project Structure & Module Organization
app/contains core backend code (Http/Controllers,Services,Models,Support,Enums).routes/web.phpdefines HTTP routes;routes/console.phpholds CLI routes.resources/viewsstores Blade templates, whileresources/jsandresources/cssare Vite frontend entry points.database/migrations,database/seeders, anddatabase/factoriesmanage schema and seed data.tests/Featurecovers HTTP/integration behavior;tests/Unitcovers isolated domain logic.public/is web root; generated assets are bundled by Vite.
Build, Test, and Development Commands
composer install— install PHP dependencies.npm install— install frontend build tooling.composer setup— one-shot project bootstrap (.env, key, migration, frontend build).composer dev— run local development stack (Laravel server, queue listener, logs, Vite).php artisan serve— run backend only.npm run dev/npm run build— start Vite dev server or build production assets.composer test(orphp artisan test) — clear config and run test suites.
Coding Style & Naming Conventions
- Follow
.editorconfig: UTF-8, LF, 4-space indent (YAML: 2 spaces), trim trailing whitespace. - PHP follows PSR-12 and Laravel conventions; format with
./vendor/bin/pintbefore PR. - Use PSR-4 namespaces under
App\with clear suffixes (*Controller,*Request,*Service). - Use
StudlyCasefor classes,camelCasefor methods/variables, andsnake_casefor DB columns/migration names.
Testing Guidelines
- Framework: PHPUnit 11 via Laravel test runner.
- Place tests in
tests/Featureortests/Unit; filename pattern:*Test.php. - Add/adjust tests for every behavioral change; prioritize Feature tests for route/controller updates.
- Keep tests deterministic; use factories/seed data and avoid external service dependencies.
Commit & Pull Request Guidelines
- Current history uses short summaries (e.g.,
init,添加 1); keep commits concise, imperative, and scoped. - Prefer format like
feat: add admin article filterorfix: validate model score bounds. - PRs should include: purpose, key changes, test evidence (
composer testoutput), and related issue IDs. - Include screenshots/GIFs for UI changes under
resources/viewsor frontend assets.
Security & Configuration Tips
- Never commit secrets from
.env; keep.env.exampleupdated for new config keys. - Use least-privilege credentials for local/dev databases.
- Validate and authorize all admin-side inputs using Form Requests and middleware.