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 the service your provider will register.
class MyService
{
    public function doSomething(): string
    {
        return 'done';
    }
}

// 2. Define your own service provider. AbstractServiceProvider only on first use

    public function register(Application $app): void
    {
        // Bind a service...
        $app->bind(MyService::class, fn() => new MyService(), true);
    }
}

// 3. Create a new application.
$app = new Application();

// 4. Register your provider.
$app->registerProvider(new MyServiceProvider());

// 5. Boot the application (register event listeners, run boot callbacks, etc.).
$app->boot();

// 6. Get your service.
$service = $app->get(MyService::class);
$service->doSomething();