PHP code example of degraciamathieu / laravel-rapid-bind

1. Go to this page and download the library: Download degraciamathieu/laravel-rapid-bind library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

degraciamathieu / laravel-rapid-bind example snippets




namespace App\Providers;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        RapidBind::bind([
            '../app/Domain/Ports/Repositories',
        ]);
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        //
    }
}



namespace App\Domain\Ports\Repositories;

use DeGraciaMathieu\RapidBind\Bind;
use App\Infrastructure\Repositories\UserRepositoryAdapter;

#[Bind(UserRepositoryAdapter::class)]
interface UserRepository
{
    //
}



namespace App\Infrastructure\Repositories;

use App\Domain\Ports\Repositories\UserRepository;

class UserRepositoryAdapter implements UserRepository
{
    //
}

$userRepository = app(UserRepository::class);

dd($userRepository); // App\Infrastructure\Repositories\UserRepositoryAdapter