VOOZH about

URL: https://deepwiki.com/invokable/laravel-boost-phpstorm-copilot/4.4-service-provider-registration

⇱ Service Provider Registration | invokable/laravel-boost-phpstorm-copilot | DeepWiki


Loading...
Last indexed: 28 February 2026 (57ef88)
Menu

Service Provider Registration

This document explains how the PhpStormCopilotServiceProvider integrates with Laravel's framework to register the PhpStormCopilot agent with the Laravel Boost system. It covers the package auto-discovery mechanism, service provider implementation, and agent registration process.

For details about the PhpStormCopilot agent class itself, see page 4.1. For information about the Laravel Boost integration architecture, see page 3.1.

Purpose and Scope

The service provider is responsible for:

  • Enabling automatic package discovery in Laravel applications
  • Registering the PhpStormCopilot agent with the Laravel\Boost\Boost facade during application bootstrap
  • Ensuring the agent is available for invocation via php artisan boost:install

Sources: src/PhpStormCopilotServiceProvider.php1-21

Package Auto-Discovery Configuration

Laravel's package auto-discovery mechanism automatically registers service providers without requiring manual configuration in the application's config/app.php file. This is configured in the package's composer.json under the extra.laravel section.

Composer Configuration

KeyValuePurpose
extra.laravel.providers["Revolution\\Laravel\\Boost\\PhpStormCopilotServiceProvider"]Declares the service provider class for auto-discovery

Sources: composer.json47-52

Auto-Discovery Flow

Diagram: Package Auto-Discovery to Service Provider Boot


Sources: composer.json47-52 src/PhpStormCopilotServiceProvider.php1-21

The auto-discovery process occurs during composer install or composer update when Laravel scans installed packages for provider declarations. This eliminates the need for manual service provider registration by end users.

Service Provider Implementation

The PhpStormCopilotServiceProvider extends Illuminate\Support\ServiceProvider and follows Laravel's service provider contract. It implements two lifecycle methods: register() and boot().

Class Structure

Diagram: Class Relationships — PhpStormCopilotServiceProvider


Sources: src/PhpStormCopilotServiceProvider.php1-21

Method Implementations

The register() method is intentionally left empty as this package does not bind any services into the Laravel service container. All registration logic occurs in the boot() method.

The boot() method calls Boost::registerAgent(), passing the string key 'phpstorm-copilot' and the PhpStormCopilot::class constant. This stores the agent in the Laravel Boost registry, making it available to the boost:install Artisan command.

Sources: src/PhpStormCopilotServiceProvider.php12-20

Lifecycle Timing

MethodWhen CalledPurpose
register()During application bootstrap, before other providers are bootedBind services into container — intentionally empty in this package
boot()After all providers are registeredCalls Boost::registerAgent() to wire PhpStormCopilot into the Laravel Boost system

Agent Registration Process

The registration process connects the package to the Laravel Boost framework by calling Boost::registerAgent() with two parameters:

ParameterValueDescription
$name'phpstorm-copilot'Unique identifier for the agent, used in CLI commands and configuration
$classPhpStormCopilot::classFully qualified class name of the agent implementation

Registration Flow Diagram

Diagram: boot() → registerAgent() → boost:install Resolution


Sources: src/PhpStormCopilotServiceProvider.php17-19

When a user runs php artisan boost:install and selects the phpstorm-copilot agent, Laravel Boost queries the agent registry, retrieves the PhpStormCopilot class reference, instantiates it, and invokes its installation methods.

Agent Registry Structure

After registration, the Laravel Boost agent registry holds a map of string keys to class references. The key 'phpstorm-copilot' maps to Revolution\Laravel\Boost\PhpStormCopilot::class. This registry is accessed via Boost::getAgents() and is used by Laravel Boost to present available agents in the installation command and resolve agent implementations at runtime.

Sources: tests/Feature/PhpStormCopilotServiceProviderTest.php8-13

Verification and Testing

The package includes a test that verifies successful registration with the Laravel Boost system.

Test Implementation

Diagram: Service Provider Test Assertions


Sources: tests/Feature/PhpStormCopilotServiceProviderTest.php1-14

The test performs two assertions:

  1. Key Existence: Verifies 'phpstorm-copilot' exists in the agent registry
  2. Class Binding: Confirms the value is the correct class reference PhpStormCopilot::class

Test Execution

Run the service provider test with:

vendor/bin/pest tests/Feature/PhpStormCopilotServiceProviderTest.php

This test ensures that:

  • The service provider's boot() method executes successfully
  • The Boost::registerAgent() call completes without errors
  • The agent is retrievable from the registry with the correct class binding

Sources: tests/Feature/PhpStormCopilotServiceProviderTest.php8-13 composer.json56

Registration Dependencies

The registration process depends on the following components being available:

Runtime Dependencies

ComponentNamespacePurpose
ServiceProviderIlluminate\Support\ServiceProviderBase class for Laravel service providers
BoostLaravel\Boost\BoostFacade for agent registration
PhpStormCopilotRevolution\Laravel\Boost\PhpStormCopilotAgent implementation class

Sources: src/PhpStormCopilotServiceProvider.php5-9 composer.json12-16

Composer Dependencies

The package requires laravel/boost: ^2.0 which provides the Boost::registerAgent() functionality. Without this dependency, the service provider's boot() method would fail with a class not found error.

Sources: composer.json15