PHP code example of caiquebispo / blade-slim

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

    

caiquebispo / blade-slim example snippets


use BladeSlim\Blade;
use Slim\Factory\AppFactory;

$app = AppFactory::create();

// Blade Configuration
$blade = new Blade(
    __DIR__ . '/../resources/views', // Views directory
    __DIR__ . '/../storage/cache',   // Cache directory
    $app->getResponseFactory()->createResponse() // Response prototype
);

$app->get('/', function () {
    return view('home', [
        'title' => 'Home Page',
        'appName' => 'My Slim App'
    ]);
});

return view('error', ['message' => 'Not Found'], 404);

$blade->getFactory()->directive('datetime', function ($expression) {
    return " echo ($expression)->format('d/m/Y H:i');