PHP code example of maymeow / php-color

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

    

maymeow / php-color example snippets


use MayMeow\PHPColor\Color;
// ...
$color = new Color(198, 255, 32);
$hex = Color::convertToHex($color); //#c6ff20

use MayMeow\PHPColor\Color;
// ...
try {
    $rgb = Color::convertToRGB($hex); // color object: Color(198, 255, 32)
} catch (\MayMeow\PHPColor\Exceptions\NotHexException $exception)
{
    // do something, echo message or log ...
}


composer