PHP code example of jdz / cssmaker

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

    

jdz / cssmaker example snippets




use JDZ\CssMaker\CssMaker;

// Initialize with optional custom output handler
$cssMaker = new CssMaker();

// Set build paths (creates directory structure automatically)
$cssMaker->setBuildPaths('/path/to/project', 'build');

// Add LESS files by category
$cssMaker->addLessFiles([
    'variables' => ['config/variables.yml'],
    'mixins' => ['src/mixins.less'],
    'normalize' => ['src/normalize.less'],
    'structure' => ['src/layout.less', 'src/components.less'],
    'mobile' => ['src/mobile.less'],
    'print' => ['src/print.less']
]);

// Add fonts (optional)
// see jdz/fontmanager for more infos
$fontData = (object) [
    'id' => 'roboto',
    'family' => 'Roboto',
    'display' => 'swap',
    'style' => 'normal',
    'weight' => '400',
    'files' => ['fonts/roboto.woff2', 'fonts/roboto.woff']
];
$cssMaker->addFont($fontData);

// Process and build CSS (creates: theme.less, theme.css, theme.min.css)
$cssMaker->process('theme');

use JDZ\CssMaker\Variables;

// Variables support YAML files
$variables = new Variables();
$variables->set('primary-color', '#3498db');
$variables->set('screen-breakpoint', '768px');

// YAML format (variables.yml):
# primary_color: "#3498db"
# screen_breakpoint: "768px"
# font_sizes:
#   small: "12px"
#   medium: "16px"
#   large: "24px"

use JDZ\Output\Output;

$output = new Output();
$output->setVerbosity(Output::VERBOSITY_ALL);

$cssMaker = new CssMaker($output);
// Now you'll see detailed processing information

use JDZ\CssMaker\Exception\LessMakerException;

try {
    $cssMaker->process('theme');
} catch (LessMakerException $e) {
    // Handle CssMaker-specific errors
    echo "CSS Build Error: " . $e->getMessage();
} catch (\Exception $e) {
    // Handle general errors
    echo "General Error: " . $e->getMessage();
}

use JDZ\Output\Output;

$output = new Output();
$output->setVerbosity(Output::VERBOSITY_ALL);

$cssMaker = new CssMaker($output);
// Detailed processing information will be displayed