PHP code example of gymmed / svg-parser

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

    

gymmed / svg-parser example snippets


use GymMed\SvgParser;

//provide full path
$svgPath = realpath(__DIR__ . "./assets/example.svg");
$cssPath = realpath(__DIR__ . "./assets/css/index.css");

$svgWithCSS = SvgParser::formatSvgFromPath($svgPath, [$cssPath]);

use GymMed\SvgParser;

//provide full path
$svgPath = realpath(__DIR__ . "./assets/example.svg");
$cssPath = realpath(__DIR__ . "./assets/css/index.css");
$svg = file_get_contents($svgPath);

$svgWithCSS = SvgParser::formatSvg($svg, [$cssPath]);

use GymMed\SvgParser;

//provide full path
$svgPath = realpath(__DIR__ . "./assets/example.svg");
$svg = file_get_contents($svgPath);

$svgWithCSS = SvgParser::getParsedCSSToSvg($svg, ".circle { background-color: red; border-radius: 50% }");

use GymMed\SvgParser;

//provide full path
$svgPath = realpath(__DIR__ . "./assets/example.svg");

$svgWithCSS = SvgParser::getParsedCSSToSvgFromPath($svgPath, ".circle { background-color: red; border-radius: 50% }");
bash
composer