1. Go to this page and download the library: Download bite/service-discovery 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/ */
bite / service-discovery example snippets
use Bite\ServiceDiscovery\DI\ServiceDiscoveryExtension;
public function bootWebApplication(): Container
{
$this->initializeEnvironment();
ServiceDiscoveryExtension::boot($this->rootDir.'/temp'); # add just before $configurator->createContainer()
return $this->configurator->createContainer();
}
use Bite\ServiceDiscovery\Attributes\Service;
#[Service]
class TokenManager
{}
use Bite\ServiceDiscovery\Attributes\EventListener;
#[EventListener]
class UserRegisteredListener
{
public function handle(UserRegisteredEvent $event): void # handle event
{}
}
use Bite\ServiceDiscovery\Attributes\Excluded;
use App\Model\Abstract\AbstractModel;
#[Excluded] # overrides discovery by-type
class ShiftControl extends AbstractControl
{
public function __construct(
private readonly AbstractModel $model,
) {}
}
#[Service(lazy: false)]
class TokenManager
{}
use App\Core\DI\AsService;
use App\Core\DI\Injectable;
class TokenService implements AsService
{}
class AbstractControl extends Control implements Injectable
{}
use Bite\ServiceDiscovery\Attributes\Service;
#[Service]
class TokenService
{}
neon
discovery:
lazy: false # PHP 8.1+
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.