PHP code example of divengine / laze

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

    

divengine / laze example snippets




ivengine\laze;

laze::define('APP_NAME', fn () => 'Laze Demo');

echo laze::read('APP_NAME');



laze::define('FOO', fn () => 1);
laze::define('FOO', fn () => 2);

echo laze::read('FOO'); // 2

laze::define('FOO', fn () => 3);
echo laze::read('FOO'); // still 2



laze::constraint(
    'APP_PORT must be an int',
    fn ($key, $value) => $key === 'APP_PORT' ? is_int($value) : true
);

laze::define('APP_PORT', fn () => 8080);



use divengine\laze;

$reflection = new ReflectionClass(laze::class);

$store = $reflection->getProperty('store');
$store->setAccessible(true);
$store->setValue(null, []);

$constraints = $reflection->getProperty('constraints');
$constraints->setAccessible(true);
$constraints->setValue(null, []);

$evaluated = $reflection->getProperty('evaluated');
$evaluated->setAccessible(true);
$evaluated->setValue(null, []);