PHP code example of ah-b / oil

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

    

ah-b / oil example snippets


composer 

$pipelineService = new OilService(new Pipeline());

$pipelineService->add(new Test());

$pipelineService->run('my payload');



class Test
{
    public function __invoke($payload)
    {
        return $payload;
    }
}


$pipelineService = new OilService(new Mediator());

$pipelineService->add(function($payload){ echo $payload; });

$pipelineService->run('my payload');





    public function indexController()
    {
    
        $databaseRecord = "test";
        
        if($databaseRecord == "test")
        {
            // do some logic
        
        }
        
        if($databaseRecord == "foo")
        {
            // do some logic
        
        }        
        
        if($databaseRecord == "bar")
        {
            // do some logic
        
        }  
        
        
        ...
    
    }





    public function indexController()
    {
    
        $databaseRecord = "test";
        
        $pipelineService = new OilService(new Pipeline());
        
        $pipelineService->add(new Test());
        
        $pipelineService->add(new Foo());
        
        $pipelineService->add(new Bar());
        
        $pipelineService->run($databaseRecord);
        
        ...
    
    }