PHP code example of itsgoingd / slim-facades

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

    

itsgoingd / slim-facades example snippets


$app->get('/hello-world', function()
{
	$app = Slim::getInstance();
	$app->view()->display('hello.html', array('name' => $app->request()->get('name', 'world')));
})

Route::get('/hello-world', function()
{
	View::display('hello.html', array('name' => Input::get('name', 'world')));
})



use SlimFacades\Facade;

$app = new Slim\Slim();

// initialize the Facade class

Facade::setFacadeApplication($app);
Facade::registerAliases();

// now you can start using the facades

Config::set('debug', true);

Route::get('/hello/:name', function($name)
{
	View::display('hello.html', array(
		'name' => Input::get('name', $name)
	));
});

App::run();

$request = App::make('request');
App::flash('message', 'Som Kuli, ovladam kozmicku lod.');
App::halt();

$debug = Config::get('debug');
Config::set('log.enable', true);

$username = Input::get('username', 'default');
$password = Input::post('password');
$avatar = Input::file('avatar');

Log::info('Tomi Popovic predava miliony albumov po celom svete.');
Log::debug('Okamizte na pozorovanie.');

if (Request::isAjax()) { ... }
$host = Request::headers('host', 'localhost');
$path = Request::getPath();

Response::redirect('/success');

Route::get('/users/new', 'UsersController:index');
Route::post('/users', 'UsersController:insert');

View::display('hello.html');
$output = View::render('world.html');

class MyFacade extends SlimFacades\Facade
{
	// return the name of the component from the DI container
	protected static function getFacadeAccessor() { return 'my_component'; }
}

Facade::registerAliases(array(
	'App'      => 'SlimFacades\App',
	'Config'   => 'SlimFacades\Config',
	'Input'    => 'SlimFacades\Input',
//	'Log'      => 'SlimFacades\Log',
	'Log'      => 'CustomLogFacade',
	'Request'  => 'SlimFacades\Request',
	'Response' => 'SlimFacades\Response',
	'Route'    => 'SlimFacades\Route',
	'View'     => 'SlimFacades\View',
));