PHP code example of tylerjuniorcollege / slim-layout

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

    

tylerjuniorcollege / slim-layout example snippets


$app = new \Slim\Slim(array(
  'view'           => new \TJC\ViewLayout(),
  'templates.path' => 'templates'
));

$app->view->setLayout('layout.php');

echo $data['content'];

$app->view->setLayoutData('user', new \App\User('someusername'));

// OR
$app->view->setLayoutData(array('user' => new \App\User('someusername')));

$app->view->getLayoutData(); // returns the full layout data array without the content.

$app->view->getLayoutData('user'); // Returns the 'user' array value.

$app->view->disableLayout()