Upgrade Guide: 2.x to 3.0
This guide summarizes required changes when upgrading Quantum projects from 2.x to 3.0.
1. Platform Requirements
- Minimum PHP version is now
7.4. - PHP
7.3and older are no longer supported.
2. Route and Middleware Response Contract
3.0 enforces explicit Quantum\Http\Response returns.
- Route handlers must return
Response. - Middleware
apply()must returnResponse. redirect()andredirectWith()now returnResponseand should be returned by caller.
Before:
$route->get('home', function ($response) {
$response->html('ok');
});
After:
$route->get('home', function (): Quantum\Http\Response {
return response()->html('ok');
});
3. Request and Response Access
Request and Response are now instance-based in runtime flow.
- Use
request()andresponse()helpers. - Remove assumptions based on static facade behavior.
4. Dependency Injection Is Stricter
Di::get()no longer auto-registers dependencies.- Dependencies must be explicitly registered before retrieval.
Typical pattern:
if (!Di::isRegistered(SomeService::class)) {
Di::register(SomeService::class);
}
$service = Di::get(SomeService::class);
5. Renamed Base Classes
Update references:
Quantum\Service\QtService->Quantum\Service\ServiceQuantum\Middleware\QtMiddleware->Quantum\Middleware\MiddlewareQuantum\Migration\QtMigration->Quantum\Migration\MigrationQuantum\Console\QtCommand->Quantum\Console\CliCommand
6. Environment API Changes
Environmentis no longer a static singleton.- Use
environment()helper and methods likeisProduction(),isTesting(),isStaging(),isDevelopment(),isLocal().
7. Model and DB Behavior Updates
DbModelfetch methods now return new model instances instead of mutating current model.create()resets model state before insert flows.- DB-generated primary keys are synced back after save.
8. Router and Execution Changes
- Middleware ordering is prepend-based (later middleware wraps earlier).
- Route name uniqueness is validated at build time.
- Legacy implicit controller resolution paths were removed.
9. Upgrade Verification Checklist
After code changes, run:
vendor/bin/phpunit
composer phpstan
composer cs:check
Then smoke-test:
- Authentication routes
- Redirect/error flows
- Middleware validation branches
- Pagination and model fetch flows