PHP code example of ytake / starch

1. Go to this page and download the library: Download ytake/starch 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/ */

    

ytake / starch example snippets


interface AnyInterface 
{

}

final class Any implements AnyInterface 
{
  // any
}

use Ytake\Starch\Container;
use Ytake\Starch\Scope;

$container = new Container();
$container->bind(AnyInterface::class)
  ->to(Any::class)
  ->in(Scope::PROTOTYPE);

$container->get(AnyInterface::class);

use Ytake\Starch\ProviderInterface;

final class AnyProvider implements ProviderInterface {

  public function get(): AnyInterface {
    return new Any();
  }
}

$container->bind(AnyInterface::class)
  ->provider(new AnyProvider();