2025-12-09 21:32:51 +00:00
|
|
|
# Phred
|
|
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
A PHP MVC framework intended for projects of all sizes, designed for both solo and team development.
|
2025-12-15 15:15:49 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
## Requirements
|
Implement M5 service providers, M6 MVC bases, and URL extension negotiation; update docs and tests
• M5: Add ServiceProviderInterface and ProviderRepository; integrate providers into Kernel (register before container build, boot after); add RouteRegistry with clear(); add default core providers (Routing, Template, ORM, Flags, Testing) and AppServiceProvider; add contracts and default drivers (Template/Eyrie, Orm/Pairity, Flags/Flagpole, Testing/Codeception)
• Routing: allow providers to contribute routes; add ProviderRouteTest
• Config: add config/providers.php; extend config/app.php with driver keys; document env keys
• M6: Introduce MVC bases: Controller, APIController (JSON helpers), ViewController (html + renderView helpers), View (transformData + renderer); add ViewWithDefaultTemplate and default-template flow; adjust method signatures to data-first and delegate template override to View
• HTTP: Add UrlExtensionNegotiationMiddleware (opt-in via URL_EXTENSION_NEGOTIATION, whitelist via URL_EXTENSION_WHITELIST with default json|php|none); wire before ContentNegotiationMiddleware
• Tests: add UrlExtensionNegotiationTest and MvcViewTest; ensure RouteRegistry::clear prevents duplicate routes in tests
• Docs: Update README with M5 provider usage, M6 MVC examples and template selection conventions, and URL extension negotiation; mark M5 complete in MILESTONES; add M12 task to provide XML support and enable xml in whitelist by default
2025-12-15 22:08:57 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
* **PHP**: 8.2+
|
|
|
|
|
* **Web Server**: Apache/Nginx (recommended)
|
|
|
|
|
* **Package Manager**: Composer
|
Implement M5 service providers, M6 MVC bases, and URL extension negotiation; update docs and tests
• M5: Add ServiceProviderInterface and ProviderRepository; integrate providers into Kernel (register before container build, boot after); add RouteRegistry with clear(); add default core providers (Routing, Template, ORM, Flags, Testing) and AppServiceProvider; add contracts and default drivers (Template/Eyrie, Orm/Pairity, Flags/Flagpole, Testing/Codeception)
• Routing: allow providers to contribute routes; add ProviderRouteTest
• Config: add config/providers.php; extend config/app.php with driver keys; document env keys
• M6: Introduce MVC bases: Controller, APIController (JSON helpers), ViewController (html + renderView helpers), View (transformData + renderer); add ViewWithDefaultTemplate and default-template flow; adjust method signatures to data-first and delegate template override to View
• HTTP: Add UrlExtensionNegotiationMiddleware (opt-in via URL_EXTENSION_NEGOTIATION, whitelist via URL_EXTENSION_WHITELIST with default json|php|none); wire before ContentNegotiationMiddleware
• Tests: add UrlExtensionNegotiationTest and MvcViewTest; ensure RouteRegistry::clear prevents duplicate routes in tests
• Docs: Update README with M5 provider usage, M6 MVC examples and template selection conventions, and URL extension negotiation; mark M5 complete in MILESTONES; add M12 task to provide XML support and enable xml in whitelist by default
2025-12-15 22:08:57 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
## Installation
|
Implement M5 service providers, M6 MVC bases, and URL extension negotiation; update docs and tests
• M5: Add ServiceProviderInterface and ProviderRepository; integrate providers into Kernel (register before container build, boot after); add RouteRegistry with clear(); add default core providers (Routing, Template, ORM, Flags, Testing) and AppServiceProvider; add contracts and default drivers (Template/Eyrie, Orm/Pairity, Flags/Flagpole, Testing/Codeception)
• Routing: allow providers to contribute routes; add ProviderRouteTest
• Config: add config/providers.php; extend config/app.php with driver keys; document env keys
• M6: Introduce MVC bases: Controller, APIController (JSON helpers), ViewController (html + renderView helpers), View (transformData + renderer); add ViewWithDefaultTemplate and default-template flow; adjust method signatures to data-first and delegate template override to View
• HTTP: Add UrlExtensionNegotiationMiddleware (opt-in via URL_EXTENSION_NEGOTIATION, whitelist via URL_EXTENSION_WHITELIST with default json|php|none); wire before ContentNegotiationMiddleware
• Tests: add UrlExtensionNegotiationTest and MvcViewTest; ensure RouteRegistry::clear prevents duplicate routes in tests
• Docs: Update README with M5 provider usage, M6 MVC examples and template selection conventions, and URL extension negotiation; mark M5 complete in MILESTONES; add M12 task to provide XML support and enable xml in whitelist by default
2025-12-15 22:08:57 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
Install Phred via Composer:
|
Refactor M7 module scaffolding, route inclusion, and tests; implement providers discovery; fix URL extension negotiation; clean docs
• Add Service Providers loading from config/providers.php and merge with runtime config; ensure AppServiceProvider boots and contributes routes
• Create RouteGroups and guard module route includes in routes/web.php; update Kernel to auto-mount module routes and apply provider routes
• Implement create:module as a console Command (extends Phred\Console\Command):
◦ Args: name, prefix; Flags: --update-composer, --no-dump
◦ Stable root resolution (dirname(DIR, 2)); robust args/flags handling under ArrayInput
◦ Scaffolds module dirs (Controllers, Views, Templates, Routes, Providers, etc.), ensures Controllers exists, adds .gitkeep
◦ Writes Provider, View, Controller, Template stubs (fix variable interpolation via placeholders)
◦ Appends guarded include snippet to routes/web.php
◦ Optional composer PSR-4 mapping update (+ backup) and optional autoload dump
◦ Prevents providers.php corruption via name validation and existence checks
• Add URL extension negotiation middleware tweaks:
◦ Only set Accept for .json (and future .xml), never for none/php
◦ Never override existing Accept header
• Add MVC base classes (Controller, APIController, ViewController, View, ViewWithDefaultTemplate); update ViewController signature and View render contract
• Add tests:
◦ CreateModuleCommandTest with setup/teardown to snapshot/restore routes/web.php and composer.json; asserts scaffold and PSR-4 mapping
◦ ProviderRouteTest for provider-contributed route
◦ UrlExtensionNegotiationTest sets API_FORMAT=rest and asserts content-type behavior
◦ MvcViewTest validates transformData+render
• Fix config/providers.php syntax and add comment placeholder for modules
• Update README: M5/M6/M7 docs, MVC examples, template selection conventions, modules section, URL extension negotiation, and module creation workflow
• Update MILESTONES.md: mark M6/M7 complete; add M8 task for register:orm; note M12 XML extension support
2025-12-16 22:14:22 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
```bash
|
|
|
|
|
composer create-project getphred/phred
|
|
|
|
|
```
|
Implement M5 service providers, M6 MVC bases, and URL extension negotiation; update docs and tests
• M5: Add ServiceProviderInterface and ProviderRepository; integrate providers into Kernel (register before container build, boot after); add RouteRegistry with clear(); add default core providers (Routing, Template, ORM, Flags, Testing) and AppServiceProvider; add contracts and default drivers (Template/Eyrie, Orm/Pairity, Flags/Flagpole, Testing/Codeception)
• Routing: allow providers to contribute routes; add ProviderRouteTest
• Config: add config/providers.php; extend config/app.php with driver keys; document env keys
• M6: Introduce MVC bases: Controller, APIController (JSON helpers), ViewController (html + renderView helpers), View (transformData + renderer); add ViewWithDefaultTemplate and default-template flow; adjust method signatures to data-first and delegate template override to View
• HTTP: Add UrlExtensionNegotiationMiddleware (opt-in via URL_EXTENSION_NEGOTIATION, whitelist via URL_EXTENSION_WHITELIST with default json|php|none); wire before ContentNegotiationMiddleware
• Tests: add UrlExtensionNegotiationTest and MvcViewTest; ensure RouteRegistry::clear prevents duplicate routes in tests
• Docs: Update README with M5 provider usage, M6 MVC examples and template selection conventions, and URL extension negotiation; mark M5 complete in MILESTONES; add M12 task to provide XML support and enable xml in whitelist by default
2025-12-15 22:08:57 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
## Getting Started
|
2025-12-14 23:10:01 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
### Creating a Module
|
2025-12-14 23:10:01 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
Phred uses a modular (Django-style) architecture. All your application logic lives inside modules.
|
2025-12-14 23:10:01 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
To scaffold a new module:
|
2025-12-14 23:10:01 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
```bash
|
|
|
|
|
php phred create:module Blog
|
2025-12-14 23:10:01 +00:00
|
|
|
```
|
|
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
This will create the module structure under `modules/Blog`, register the service provider, and mount the routes.
|
2025-12-14 23:10:01 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
After creating a module, update your `composer.json` to include the new namespace:
|
2025-12-14 23:10:01 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"autoload": {
|
|
|
|
|
"psr-4": {
|
|
|
|
|
"Project\\\\Modules\\\\Blog\\\\": "modules/Blog/"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
2025-12-14 23:10:01 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
Then run:
|
|
|
|
|
```bash
|
|
|
|
|
composer dump-autoload
|
2025-12-14 23:10:01 +00:00
|
|
|
```
|
|
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
### Running the Application
|
|
|
|
|
|
|
|
|
|
Start the local development server:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
php phred run
|
2025-12-14 23:10:01 +00:00
|
|
|
```
|
2025-12-15 02:09:06 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
The application will be available at `http://localhost:8000`.
|
2025-12-15 02:09:06 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
## CLI Usage (phred)
|
2025-12-15 02:09:06 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
The `phred` binary provides several utility and scaffolding commands.
|
2025-12-15 02:09:06 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
### Generators
|
|
|
|
|
* `php phred create:module <name>` — Create a new module.
|
|
|
|
|
* `php phred create:command <name>` — Create a custom CLI command.
|
|
|
|
|
* `php phred create:<module>:controller <name>` — Create a controller.
|
|
|
|
|
* `php phred create:<module>:view <name>` — Create a view and template.
|
|
|
|
|
* `php phred create:<module>:model <name>` — Create a domain model.
|
|
|
|
|
* `php phred create:<module>:migration <name>` — Create a migration.
|
|
|
|
|
* `php phred create:<module>:seed <name>` — Create a database seeder.
|
|
|
|
|
* `php phred create:<module>:test <name>` — Create a test.
|
2025-12-15 02:09:06 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
### Database
|
|
|
|
|
* `php phred migrate` — Run database migrations.
|
|
|
|
|
* `php phred migration:rollback` — Rollback migrations.
|
|
|
|
|
* `php phred seed` — Seed the database.
|
|
|
|
|
* `php phred db:backup` — Backup the database.
|
|
|
|
|
* `php phred db:restore` — Restore the database.
|
2025-12-15 15:15:49 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
### Testing & Utilities
|
|
|
|
|
* `php phred test` — Run tests for the entire project.
|
|
|
|
|
* `php phred test:<module>` — Run tests for a specific module.
|
|
|
|
|
* `php phred list` — List all available commands.
|
2025-12-15 15:15:49 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
## Technical Specifications
|
2025-12-15 02:09:06 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
For detailed information on the framework architecture, service providers, configuration, and MVC components, please refer to:
|
2025-12-15 02:09:06 +00:00
|
|
|
|
2025-12-23 23:39:06 +00:00
|
|
|
👉 **[SPECS.md](./SPECS.md)** | [MILESTONES.md](./MILESTONES.md)
|
|
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
|
|
Phred is open-source software licensed under the MIT license.
|