Phred/MILESTONES.md

266 lines
15 KiB
Markdown
Raw Normal View History

2025-12-14 23:10:01 +00:00
# Phred Framework Milestones
[← Back to README](./README.md) | [SPECS.md](./SPECS.md)
2025-12-14 23:10:01 +00:00
Phred supports REST and JSON:API via env setting; batteries-included defaults, swappable components.
[↑ Back to Top](#table-of-contents)
## Table of Contents
2026-01-06 17:02:05 +00:00
- [M0 — Project bootstrap (repo readiness)](#m0-project-bootstrap-repo-readiness)
- [M1 — Core HTTP kernel and routing](#m1-core-http-kernel-and-routing)
- [M2 — Configuration and environment](#m2-configuration-and-environment)
- [M3 — API formats and content negotiation](#m3-api-formats-and-content-negotiation)
- [M4 — Error handling and problem details](#m4-error-handling-and-problem-details)
- [M5 — Dependency Injection and Service Providers](#m5-dependency-injection-and-service-providers)
- [M6 — MVC: Controllers, Views, Templates](#m6-mvc-controllers-views-templates)
- [M7 — Modules (Djangostyle app structure)](#m7-modules-django-style-app-structure)
- [M8 — Database access, migrations, and seeds](#m8-database-access-migrations-and-seeds)
- [M9 — CLI (phred) and scaffolding](#m9-cli-phred-and-scaffolding)
- [M10 — Security middleware and auth primitives](#m10-security-middleware-and-auth-primitives)
- [M11 — Logging, HTTP client, and filesystem](#m11-logging-http-client-and-filesystem)
- [M12 — Serialization/validation utilities and pagination](#m12-serialization-validation-utilities-and-pagination)
- [M13 — OpenAPI and documentation](#m13-openapi-and-documentation)
- [M14 — Testing, quality, and DX](#m14-testing-quality-and-dx)
- [M15 — Caching and performance (optional default)](#m15-caching-and-performance-optional-default)
- [M16 — Production hardening and deployment](#m16-production-hardening-and-deployment)
- [M17 — JSON:API enhancements (optional package)](#m17-json-api-enhancements-optional-package)
- [M18 — Examples and starter template](#m18-examples-and-starter-template)
- [M19 — Documentation site](#m19-documentation-site)
- [M20 — Dynamic Command Help](#m20-dynamic-command-help)
- [M21 — Governance and roadmap tracking](#m21-governance-and-roadmap-tracking)
2026-01-06 17:02:05 +00:00
## M0 — Project bootstrap (repo readiness)
* Tasks:
- [x] Finalize `composer.json` (namespaces, scripts, suggests) and `LICENSE`.
- [x] Add `.editorconfig`, `.gitattributes`, `.gitignore`, example `.env.example`.
- [x] Set up CI (lint, static analysis, unit tests) and basic build badge.
* Acceptance:
- [x] Fresh clone installs (without running suggested packages) and passes linters/analysis/tests.
[↑ Back to Top](#table-of-contents)
2026-01-06 17:02:05 +00:00
## M1 — Core HTTP kernel and routing
* Tasks:
- [x] Implement the HTTP kernel: `PSR-15` pipeline via `Relay`.
- [x] Wire `nyholm/psr7(-server)` factories and server request creation.
- [x] Integrate `nikic/fast-route` with a RouteCollector and dispatcher.
- [x] Define route → controller resolution (invokable controllers).
- [x] Add minimal app bootstrap (front controller) and DI container wiring (`PHP-DI`).
- [x] Addendum: Route groups (prefix only) via `Router::group()`
* Acceptance:
- [x] Sample route returning a JSON 200 via controller.
- [x] Controllers are invokable (`__invoke(Request)`), one route per controller.
- [x] Route groups (prefix only) work and are tested.
[↑ Back to Top](#table-of-contents)
2026-01-06 17:02:05 +00:00
## M2 — Configuration and environment
* Tasks:
- [x] Load `.env` via `vlucas/phpdotenv` and expose `Phred\Support\Config`.
- [x] Define configuration precedence and document keys (e.g., `API_FORMAT`, `APP_ENV`, `APP_DEBUG`).
* Acceptance:
- [x] App reads config from `.env`; unit test demonstrates override behavior.
[↑ Back to Top](#table-of-contents)
2026-01-06 17:02:05 +00:00
## M3 — API formats and content negotiation
* Tasks:
- [x] Finalize `ContentNegotiationMiddleware` using `.env` and `Accept` header.
- [x] Bind `ApiResponseFactoryInterface` to `RestResponseFactory` or `JsonApiResponseFactory` based on format.
- [x] Provide developerfacing helpers for common responses (`ok`, `created`, `error`).
* Acceptance:
- [x] Demo endpoints respond correctly as REST or JSON:API depending on `API_FORMAT` and `Accept`.
[↑ Back to Top](#table-of-contents)
2026-01-06 17:02:05 +00:00
## M4 — Error handling and problem details
* Tasks:
- [x] Finalize `ProblemDetailsMiddleware` with RFC7807 (REST) and JSON:API error documents.
- [x] Integrate `filp/whoops` for dev mode (`APP_DEBUG=true`).
- [x] Map common exceptions to HTTP status codes; include correlation/request IDs in responses/logs.
* Acceptance:
- [x] Throwing an exception yields a standardscompliant error response; debug mode shows Whoops page.
[↑ Back to Top](#table-of-contents)
2026-01-06 17:02:05 +00:00
## M5 — Dependency Injection and Service Providers
* Tasks:
- [x] Define Service Provider interface and lifecycle (register, boot).
- [x] Module discovery loads providers in order (core → app → module).
- [x] Add examples for registering controllers, services, config, and routes via providers.
- [x] Define contracts: `Template\Contracts\RendererInterface`, `Orm\Contracts\*`, `Flags\Contracts\FeatureFlagClientInterface`, `Testing\Contracts\TestRunnerInterface`.
- [x] Define config/env keys for driver selection (e.g., `TEMPLATE_DRIVER`, `ORM_DRIVER`, `FLAGS_DRIVER`, `TEST_RUNNER`).
- [x] Provide “default adapter” Service Providers for the shipped packages and document swap procedure.
* Acceptance:
- [x] Providers can contribute bindings and routes; order is deterministic and tested.
- [x] Drivers can be switched via `.env`/config without changing controllers/services; example provider route covered by tests.
[↑ Back to Top](#table-of-contents)
2026-01-06 17:02:05 +00:00
## M6 — MVC: Controllers, Views, Templates
* Tasks:
- [x] Controller base class and conventions (request/response helpers).
- [x] View layer (data preparation) with `getphred/eyrie` template engine integration.
- [x] Template rendering helper: `$this->render(<template>, <data>)`.
* Acceptance:
- [x] Example page rendered through View → Template; API coexists with fullsite rendering.
- [x] Rendering works via RendererInterface and can be swapped (e.g., Eyrie → Twig demo) with only configuration/provider changes.
[↑ Back to Top](#table-of-contents)
2026-01-06 17:02:05 +00:00
## M7 — Modules (Djangostyle app structure)
* Tasks:
- [x] Define module filesystem layout (Nested Controllers/Views/Services/Models/Templates/Routes/Tests).
- [x] Module loader: autoregister providers, routes, templates.
- [x] Namespacing and autoload guidance.
- [x] Core CLI: add `create:module <name>` command to scaffold a module with nested resources.
- [x] ORMagnostic module layout (to support Pairity DAO/DTO and Eloquent Active Record):
- [x] `Modules/<X>/Models/` — domain models (pure PHP, ORMneutral)
- [x] `Modules/<X>/Repositories/` — repository interfaces (DI targets for services)
- [x] `Modules/<X>/Persistence/Pairity/` — DAOs, DTOs, mappers, repository implementations
- [x] `Modules/<X>/Persistence/Eloquent/` — Eloquent models, scopes, repository implementations
- [x] `Modules/<X>/Database/Migrations/*` — canonical migrations for the module (no duplication per driver)
* Acceptance:
- [x] Creating a module with the CLI makes it discoverable; routes/templates work without manual wiring.
- [x] Switching `ORM_DRIVER` between `pairity` and `eloquent` requires no changes to services/controllers; providers bind repository interfaces to driver implementations.
[↑ Back to Top](#table-of-contents)
2026-01-06 17:02:05 +00:00
## M8 — Database access, migrations, and seeds
* Tasks:
- [x] Integrate `getphred/pairity` for ORM/migrations/seeds.
- [x] Define config (`DB_*`), migration paths (app and modules), and seeder conventions.
- [x] CLI commands: `migrate`, `migration:rollback`, `seed`, `seed:rollback`.
- [x] All persistence usage in examples goes through Orm contracts; can be swapped (Pairity → Doctrine adapter demo optional).
- [x] Add `register:orm <driver>` command:
- [x] Verify or guide installation of the ORM driver package.
- [x] Update `.env` (`ORM_DRIVER=<driver>`) safely.
- [x] Create `modules/*/Persistence/<Driver>/` directories for existing modules.
* Acceptance:
- [x] Running migrations modifies a test database; seeds populate sample data; CRUD demo works.
- [x] All persistence usage in examples goes through Orm contracts; can be swapped (Pairity → Doctrine adapter demo optional).
[↑ Back to Top](#table-of-contents)
2026-01-06 17:02:05 +00:00
## M9 — CLI (phred) and scaffolding
* Tasks:
- [x] Implement Symfony Console app in `bin/phred`.
- [x] Generators: `create:<module>:controller`, `create:<module>:model`, `create:<module>:migration`, `create:<module>:seed`, `create:<module>:test`, `create:<module>:view`.
- [x] Utility commands: `test[:<module>]`, `run`, `db:backup`, `db:restore`.
* Acceptance:
- [x] Commands generate files with correct namespaces/paths and pass basic smoke tests.
[↑ Back to Top](#table-of-contents)
2026-01-06 17:02:05 +00:00
## M10 — Security middleware and auth primitives
* Tasks:
- [x] Add CORS, Secure Headers middlewares; optional CSRF for template routes.
- [x] JWT support (lcobucci/jwt) with simple token issue/verify service.
- [x] Configuration for CORS origins, headers, methods.
- [x] Bind FeatureFlagClientInterface with a default adapter (Flagpole); add small sample usage and env config.
* Acceptance:
- [x] CORS preflight and secured endpoints behave as configured; JWTprotected route example works.
[↑ Back to Top](#table-of-contents)
2026-01-06 17:02:05 +00:00
## M11 — Logging, HTTP client, and filesystem
* Tasks:
- [x] Monolog setup with handlers and processors (request ID, memory, timing).
- [x] Guzzle PSR18 client exposure; DI binding for HTTP client interface.
- [x] Flysystem integration with local adapter; abstraction for storage disks.
- [x] Standardize all core service providers with robust driver validation (similar to OrmServiceProvider).
- [x] Opportunity Radar: Multiple storage disks, log channel management, and HTTP client middleware.
- [x] Opportunity Radar 2: Storage Disk "Cloud" Adapters (S3), Advanced HTTP Middleware (Circuit Breaker), and Log Alerting (Slack/Sentry).
- [x] Opportunity Radar 3: Githook Integration, Breadcrumb Automation, and TOC for MILESTONES.md.
- [x] Opportunity Radar 4: Middleware Groups and Centralized Route List Command.
- [x] Opportunity Radar 5: FeatureTestCase, Middleware Group Auto-Mounting, and Route Caching.
* Acceptance:
- [x] Logs include correlation IDs; sample outbound HTTP call via client; file upload/storage demo works.
[↑ Back to Top](#table-of-contents)
2026-01-06 17:02:05 +00:00
## M12 — Serialization/validation utilities and pagination
* Tasks:
- [x] REST default: Symfony Serializer normalizers/encoders; document extension points.
- [x] Add simple validation layer using `Phred\Http\Middleware\Middleware` base.
- [x] Pagination helpers (links/meta), REST and JSON:API compatible outputs.
- [x] URL extension negotiation: add XML support
- [x] Provide `XmlResponseFactory` (or encoder) and integrate with negotiation.
- [x] Enable `xml` in `URL_EXTENSION_WHITELIST` by default.
- [x] Opportunity Radar: Storage URL generation, Circuit Breaker persistence (PSR-16), and HTTP client profiling.
* Acceptance:
- [x] Example endpoint validates input, returns 422 with details; paginated listing includes links/meta.
[↑ Back to Top](#table-of-contents)
2025-12-14 23:10:01 +00:00
## M13 — OpenAPI and documentation
* Tasks:
2026-01-06 17:02:05 +00:00
- [x] Integrate `zircote/swagger-php` annotations.
- [x] CLI/task to generate OpenAPI JSON; optional serve route and Redoc UI pointer.
- [x] Document auth, pagination, error formats.
2025-12-14 23:10:01 +00:00
* Acceptance:
2026-01-06 17:02:05 +00:00
- [x] Generated OpenAPI document validates; matches sample endpoints.
[↑ Back to Top](#table-of-contents)
2025-12-14 23:10:01 +00:00
## M14 — Testing, quality, and DX
* Tasks:
2026-01-06 17:02:05 +00:00
- [x] Establish testing structure with Codeception (unit, integration, API suites).
- [x] Add fixtures/factories via Faker for examples.
- [x] PHPStan level selection and baseline; code style via php-cs-fixer ruleset.
- [x] Precommit hooks (e.g., GrumPHP) or custom git hooks for staged files.
- [x] Define TestRunnerInterface and a Codeception adapter; otherwise, state tests are run via Composer script only.
2025-12-14 23:10:01 +00:00
* Acceptance:
2026-01-06 17:02:05 +00:00
- [x] `composer test` runs green across suites; static analysis passes.
- [x] CLI tests run via TestRunnerInterface;
- [x] CLI tests run green per module and across suites.
[↑ Back to Top](#table-of-contents)
2025-12-14 23:10:01 +00:00
## M15 — Caching and performance (optional default)
* Tasks:
2026-01-06 17:02:05 +00:00
- [x] Provide `PSR-16` cache interface binding; suggest `symfony/cache` when enabled.
- [x] Simple response caching middleware and ETag/LastModified helpers.
- [x] Rate limiting middleware (token bucket) suggestion/integration point.
2025-12-14 23:10:01 +00:00
* Acceptance:
2026-01-06 17:02:05 +00:00
- [x] Sample endpoint demonstrates cached responses and conditional requests.
[↑ Back to Top](#table-of-contents)
2025-12-14 23:10:01 +00:00
## M16 — Production hardening and deployment
* Tasks:
2026-01-06 17:02:05 +00:00
- [x] Config for envs (dev/test/stage/prod), error verbosity, trusted proxies/hosts.
- [x] Docker example, PHPFPM + Nginx config templates.
- [x] Healthcheck endpoint, readiness/liveness probes.
2025-12-14 23:10:01 +00:00
* Acceptance:
2026-01-06 17:02:05 +00:00
- [x] Containerized demo serves both API and template pages; healthchecks pass.
[↑ Back to Top](#table-of-contents)
2025-12-14 23:10:01 +00:00
## M17 — JSON:API enhancements (optional package)
* Tasks:
2026-01-06 17:02:05 +00:00
- [x] If enabled, integrate `neomerx/json-api` fully: includes, sparse fieldsets, relationships, sorting, filtering, pagination params.
- [x] Adapters/Schema providers per resource type.
2025-12-14 23:10:01 +00:00
* Acceptance:
2026-01-06 17:02:05 +00:00
- [x] JSON:API conformance tests for selected endpoints pass; docs updated.
[↑ Back to Top](#table-of-contents)
2025-12-14 23:10:01 +00:00
## M18 — Examples and starter template
* Tasks:
2026-01-06 17:02:05 +00:00
- [x] Create `examples/shop` module showcasing controllers, views, templates, ORM, auth, pagination, and both API formats.
- [x] Ensure examples use the external stubs and module-specific CLI command conventions.
- [x] Provide `composer create-project` skeleton template instructions.
2025-12-14 23:10:01 +00:00
* Acceptance:
2026-01-06 17:02:05 +00:00
- [x] New users can scaffold a working app in minutes following README.
[↑ Back to Top](#table-of-contents)
2025-12-14 23:10:01 +00:00
## M19 — Documentation site
* Tasks:
2026-01-06 17:02:05 +00:00
- [x] Build the official documentation site (getphred.com) using the Phred framework.
- [x] Internal Documentation API: Design a "Documentation Module" that parses Markdown files from the repo to serve them dynamically.
- [x] Automated TOC Generation: Script to regenerate SPECS.md Table of Contents.
- [x] Versioned docs and upgrade notes.
2025-12-14 23:10:01 +00:00
* Acceptance:
2026-01-06 17:02:05 +00:00
- [x] Docs published; links in README; examples maintained.
[↑ Back to Top](#table-of-contents)
## M20 — Dynamic Command Help
* Tasks:
2026-01-06 17:02:05 +00:00
- [x] Implement a `docs` command in `phred` (e.g., `php phred docs <command>`) that opens the relevant documentation page in the user's browser.
- [x] Build the `docs` command logic after the documentation site (getphred.com) is functional.
* Acceptance:
2026-01-06 17:02:05 +00:00
- [x] `php phred docs create:module` opens the correct URL in the default browser.
[↑ Back to Top](#table-of-contents)
## M21 — Governance and roadmap tracking
2025-12-14 23:10:01 +00:00
* Tasks:
2026-01-06 17:02:05 +00:00
- [x] Define contribution guide, issue templates, RFC process for changes.
- [x] Public roadmap (this milestone list) tracked as GitHub Projects/Issues.
2025-12-14 23:10:01 +00:00
* Acceptance:
2026-01-06 17:02:05 +00:00
- [x] Contributors can propose features via RFC; roadmap is visible and updated.
[↑ Back to Top](#table-of-contents)