boson-php/uri-factory-contracts
Lightweight PHP 8.4+ contracts for URI factory implementations used in the Boson ecosystem. Install via Composer and implement the interfaces to standardize URI creation across packages and applications.
Url/Route helpers and third-party integrations (e.g., API clients, background jobs).Url to a custom resolver).Url or Route, ensuring backward compatibility.Url/Route helpers suffice, this adds unnecessary complexity. Justify only for:
Mockery or Laravel Mocks) compared to Laravel’s built-in facades.Url::to()/Route::named().Url/Route with minimal effort.class LaravelUriFactory implements \Boson\UriFactory\UriFactoryContract {
public function create(string $path, array $params = []): UriInterface {
return new \Illuminate\Http\Uri($path, $params);
}
}
client->request('GET', $factory->create('/users'))).dispatch(new SendEmail($factory->create('/emails/send')))).Url::fake() with mockable interfaces for isolated unit tests.Url::to().Url::to() calls via static analysis (e.g., PHPStan rules).Url/Route.// Legacy: Url::to('/users')
// New: app(UriFactory::class)->create('/users')
| Step | Task | Dependencies |
|---|---|---|
| 1 | Review Boson PHP’s URI handling | Boson framework docs |
| 2 | Implement UriFactoryContract |
Laravel Url facade |
| 3 | Test in isolation (unit tests) | PHPUnit/Pest |
| 4 | Integrate with a feature branch | Feature flag |
| 5 | Monitor performance/errors | Sentry/New Relic |
| 6 | Roll out to production | CI/CD pipeline |
Url won’t break custom logic if the factory acts as a stable interface.Url/Route changes.| Risk | Mitigation Strategy |
|---|---|
| Factory throws exceptions | Implement fallback to Url::to() in production. |
| Boson package becomes abandoned | Fork and maintain locally if critical. |
| URI inconsistencies | Add validation layers (e.g., enforce HTTPS). |
| Migration stalls | Use feature flags to toggle factory usage. |
Url::to() calls using rector.How can I help you explore Laravel packages today?