1. Go to this page and download the library: Download enzyme/laravel-binder 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/ */
enzyme / laravel-binder example snippets
use Enzyme\LaravelBinder\Binder;
// Inside the app service provider...
public function register()
{
$binder = new Binder($this->app);
$binder->setAlias(
'controller.listing',
'App\Http\Controllers\ListingController'
);
$binder->setAlias(
'repos.interface',
'Acme\Repositories\RepositoryInterface'
);
// Option 1 for binding, using aliases.
$binder->setBinding(
'repos.listing',
'repos.interface',
'Acme\Repositories\ListingRepository'
);
// Option 2 for binding, using FQNs.
$binder->setBinding(
'factories.listing',
'Acme\Factories\FactoryInterface',
'Acme\Factories\ListingFactory'
);
// Tell the service container that the ListingController
// needs the ListingRepository & ListingFactory.
$binder->setNeeds(
'controller.listing',
['repos.listing', 'factories.listing']
);
$binder->register();
}
// You don't need to inject the specific concrete classes, just the
// interfaces. The Binder + Service Container has taken care of it for you.
public function __construct(RepositoryInterface $repo, FactoryInterface $factory)
{
$this->repo = $repo;
$this->factory = $factory;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.