PHP code example of ibnusyuhada / slim-tegar

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

    

ibnusyuhada / slim-tegar example snippets




ll Slim Tegar
$app = new IS\Slim\Tegar\App();

// register route with Closure
$app->get("/", function($response){
    $response->write("Welcome to Slim!");
    return $response;
});

// run Slim
$app->run();


namespace App\Controllers;

class ExampleController
{
	public function index($response)
	{
		$response->write("Controller example with index as method");
		return $response;
	}
}


return [
    'settings' => [
			'displayErrorDetails' => false,
    		'ibnu' => 'syuhada'
	]
];


all Slim Tegar
$path = __DIR__ . '/config';
$app = new IS\Slim\Tegar\App($path);

// register route with Closure
$app->get("/", function($response){
    $response->write("Welcome to Slim!");
    return $response;
});

// run Slim
$app->run();



return [
	\Slim\Views\Twig::class => function (Interop\Container\ContainerInterface $c) {
		$twig = new \Slim\Views\Twig('views', [
                    'cache' => 'cache'
                ]);
		$twig->addExtension(
					new \Slim\Views\TwigExtension(
							$c->get('router'), 
							$c->get('request')->getUri()
					)
				);
        return $twig;
    }
];

$app->get('/', function ($response, Twig $twig) {
	return $twig->render($response, 'home.twig');
});