PHP code example of codepso / php-helper

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

    

codepso / php-helper example snippets



Codepso\PHPHelper\ImageHelper;

try {

    // ratio: 1 (inset)
    $p = ['path' => 'assets/files', 'filter' => '200x200'];
    $r1 = ImageHelper::createThumbnail('teddy.png', $p);
    if (!$r1->status) {
        throw new \Exception($r1->message);
    }

    // ratio: 2 (outbound)
    $p = ['path' => 'assets/files', 'filter' => '200x200', 'rename' => 'teddy-2.png',  'ratio' => 2];
    $r2 = ImageHelper::createThumbnail('teddy.png', $p);
    if (!$r2->status) {
        throw new \Exception($r2->message);
    }

} catch (\Exception $e) {
    $e->getMessage();
}


Codepso\PHPHelper\ImageHelper;

try {

    $p = [
        'filename' => 'box.png',
        'value' => 'iVBORw0KGgoAAAANSUhEUgAAABoAAAAYAQMAAADeTH+GAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAA1BMVEWIkr9Q9TFnAAAAC0lEQVQIHWMYIAAAAHgAASxSckIAAAAASUVORK5CYII='
    ];
    $r = ImageHelper::saveBase64($p, 'assets/files');
    if (!$r->status) {
        throw new \Exception($r->message);
    }

} catch (\Exception $e) {
    $e->getMessage();
}
bash
composer 
bash
php vendor/bin/codecept run unit ImageHelperTest
php vendor/bin/codecept run unit
php vendor/bin/codecept run ImageHelperTest:testSaveBase64
php vendor/bin/codecept run ImageHelperTest:testSaveBase64WithNewName