PHP code example of m3m0r7 / ez-door-sign

1. Go to this page and download the library: Download m3m0r7/ez-door-sign 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/ */

    

m3m0r7 / ez-door-sign example snippets




use Libusb\Connector\Libusb1_0;
use Libusb\Libusb;
use Libusb\LibusbHandle;
use Libusb\Loader\AutoLoader;
use EzDoorSign\EzDoorSign;
use EzDoorSign\Manipulator;

              is_dir('/opt/homebrew/Cellar/libusb')
                    ? glob('/opt/homebrew/Cellar/libusb/1.0.*') ?: []
                    : []
            ),
        )
    ),
);

$ezDoorSign = new EzDoorSign($libusb);

/**
 * @var Manipulator $manipulator
 */
[$manipulator] = $ezDoorSign->devices();

// Run refresh command
$manipulator->refresh();




use EzDoorSign\Command\renderImageCommand;
use EzDoorSign\EzDoorSign;
use EzDoorSign\Manipulator;
use Libusb\Connector\Libusb1_0;
use Libusb\Libusb;
use Libusb\LibusbHandle;
use Libusb\Loader\AutoLoader;
use EzDoorSign\Renderer\ImageRenderer;
use EzDoorSign\Renderer\TextRenderer;
use EzDoorSign\Renderer\Canvas;

       ),
        )
    ),
);

$ezDoorSign = new EzDoorSign($libusb);

/**
 * @var Manipulator $manipulator
 */
[$manipulator] = $ezDoorSign->devices();

$manipulator
    ->renderImage(

        // Specify rendering an image is here (only support image path currently)
        new Canvas(new \EzDoorSign\Renderer\ImageRenderer(__DIR__ . '/tests/example.jpg')),

        // If you want to render a text, then comment-in below code and do comment-out starting with `new Canvas(new \EzDoorSign\Renderer\ImageRenderer(...)),` in above.
        // new Canvas(new \EzDoorSign\Renderer\TextRenderer('Hello World!', '/path/to/your-fornts.ttf'))

        // Specify rendering options
        fn (renderImageCommand $renderImage) => $renderImage
            // This method means vailable to set filling color. This example is using Red color to fill.
            ->setFillColor(ColorPattern::RED)

        // Specify slot number (0-4)
        0,
    );


// ... do something

$ezDoorSign = new EzDoorSign(
    $libusb,
    // You can specify logger in the 2nd parameter of the EzDoorSign class's constructor.
    (new Logger('log'))
        ->pushHandler(new StreamHandler(STDOUT, Level::Info)),
);

// ... do something