PHP code example of xy2z / blader

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

    

xy2z / blader example snippets




$blader->addRoute('GET', '/', 'home'); // Renders '../views/home.blade.php'
$blader->addRoute('GET', '/about', 'about'); // Renders '../views/about.blade.php'

$blader->not_found_view = '404'; // Renders '../views/404.blade.php' on 404.

$blader->render();

$blader->global_vars = [
	'foo' => 'bar',
];

$blader->addRoute('GET', '/rss', 'rss', function() {
	header('Content-type: application/rss+xml; charset=utf-8');
});

$blader->addRoute('GET', '/rss', 'rss', function() {
	// Return all variables you want in the view.
	return [
		'foo' => 'bar',
	];
});

// 'views/rss.blade.php' can now print $foo

composer create-project xy2z/blader mysite
cd mysite/public
php -S 127.0.0.1:81