PHP code example of domainflow / core
1. Go to this page and download the library: Download domainflow/core 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/ */
domainflow / core example snippets
use DomainFlow\Application;
use DomainFlow\Service\AbstractServiceProvider;
// 1. Define your own service provider.
class MyServiceProvider extends AbstractServiceProvider
{
protected array $providedServices = [MyService::class];
public bool $defer = true; // Lazy loading, only load on first use
public function register(Application $app): void
{
// Bind a service...
$app->bind(MyService::class, fn() => new MyService(), true);
}
}
// 2. Create a new application.
$app = new Application();
// 3. Register your provider.
$app->registerProvider(new MyServiceProvider());
// 4. Boot the application (register event listeners, run boot callbacks, etc.).
$app->boot();
// 5. Get your service.
$service = $app->get(MyService::class);
$service->doSomething();