You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: php-sharp/laravel package joins Laravel's container with PHP# modules #55
A Laravel app that adopts PHP# has two containers: Laravel's and PHP#'s module container. Without a bridge between them, Laravel can't resolve a service a PHP# module binds, and PHP# modules can't use objects Laravel creates.
Why this matters
The Architect migrates a whole Laravel app to PHP# once v1 is done, so the two containers must work together from the first day. PHP# itself never depends on a framework, so the bridge is its own optional package, php-sharp/laravel.
Systems involved
PHP#'s module container: implements PSR-11.
Laravel's container: resolves controllers, jobs, listeners and commands.
The adapter: a Laravel service provider that does three things:
It resolves PHP#-bound services through PHP#'s container.
It exposes Laravel-created objects to PHP# modules as foreign objects.
It starts and ends PHP#'s scoped lifetime for each HTTP request, queued job and console command.
Constraints
The core PHP# runtime has no Laravel dependency.
The package is opt-in through Composer.
No attributes are used for wiring.
Done when
Laravel resolving PHP#: a Laravel controller type-hints a service bound in a Module.sharp, and receives it.
PHP# using Laravel: a PHP# module receives a Laravel-created object, such as the database connection or the cache.
Scoped lifetime: a scoped service is the same object within one request or job, and a different one in the next.
Packaging: the package installs with composer require php-sharp/laravel, and the core runtime still installs without Laravel.
Superseded by decision 078. PHP# ships no framework adapter, because each framework would need its own and PHP# would follow each framework's releases. A long-running host, Octane included, wraps each request or job in the standard library's Scope.run, so a scoped service lives for one unit of work (spec §32 host-scope, engine tests scope_run and scope_fibers). Any PSR-11 consumer, Laravel's container included, gets a PHP# service through Sharp\Psr\Container (engine test container_psr).
Activity
chore: merge Mago master 9c95c77 into the generics slice
heyJordanParker commentedon Oct 23, 2026
Superseded by decision 078. PHP# ships no framework adapter, because each framework would need its own and PHP# would follow each framework's releases. A long-running host, Octane included, wraps each request or job in the standard library's Scope.run, so a scoped service lives for one unit of work (spec §32 host-scope, engine tests scope_run and scope_fibers). Any PSR-11 consumer, Laravel's container included, gets a PHP# service through Sharp\Psr\Container (engine test container_psr).