PHP code example of tatter / handlers

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

    

tatter / handlers example snippets




namespace App\Factories;

use App\Interfaces\WidgetInterface;
use Tatter\Handlers\BaseFactory;

class WidgetFactory extends BaseFactory
{
    public const HANDLER_PATH = 'Widgets';
    public const HANDLER_TYPE = WidgetInterface::class;
}

use App\Factories\WidgetFactory;

// Iterate through all discovered handlers
foreach (WidgetFactory::findAll() as $class)
{
    $widget = new $class($param1, $param2);
    $widget->display();
}

// ... or get a single handler by specifying its ID
$class = WidgetFactory::find('FancyHandler');
(new $class)->display();