PHP code example of mzdr / micro

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

    

mzdr / micro example snippets




// Returns the instance of the Gestalt (@samrap/gestalt) library.
µ\config();

// You can pretty much do anything you like with it.
$config = µ\config();
$special_var = $config->get('my.stored.variable');


// Need to register routes with the
// FastRoute (@nikic/FastRoute) instance?
µ\router()->get('/home', function () {

    // 🌈 Use your imagination…

    // How about we use the Plates
    // (@thephpleague/plates) template engine? 🤩
    echo µ\template()->render('home');
});


// Tired of typing µ? 😫 Join the club!
namespace µ {
    router()->get('/', function () {
        $key = 'my-heavy-op';
        $ttl = 300;
        $value = "cached for $ttl seconds.";

        if (cache()->has($key) === false) {
            sleep(2); // So so heavy…

            cache()->set($key, $value, $ttl);

            return $value;
        }

        return cache()->get($key);
    });
}

// Out there in strange places? 👽 Import it!
namespace alien {
    use function µ\config;

    $done = config()->get('get.it.done');
}