Skip to content

feat: php-sharp/laravel package joins Laravel's container with PHP# modules #55

Closed as not planned

Description

@heyJordanParker

Problem

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.

Activity

  1. added
    v1
    on Oct 8, 2026
  2. added a commit that references this issue on Oct 13, 2026
  3. heyJordanParker commented on Oct 23, 2026

    @heyJordanParker
    OwnerAuthor

    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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

v1

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions