PHP code example of sbstjn / sliphp

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

    

sbstjn / sliphp example snippets


define ('SLIPHP_VIEWS', '/var/www/views/');

$view = new SliPHP\View('index');
die($view);

$layout = new SliPHP\Layout('default');
$layout->body(new SliPHP\View('index'));

die($layout);

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <title>SliPHP</title>
    <meta charset="utf-8" />
  </head>
  <body><?=$view->body()

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <title>SliPHP Example</title>
    <?=$view->block('header')

<meta charset="utf-8" />

<meta charset="utf-8" />

<?=$view->block('styles')

<strong><?=$view->apply('KATZE', 'ucfirst|strtolower')

$view = new SliPHP\View('index');

$view->helper('strong', function($value) {
    return '<strong>' . $value . '</strong>';
});

<?=$view->strong('hi')

$view->helper('css', function($file) {
    return '<link rel="stylesheet" href="' . $file . '" type="text/css" charset="utf-8" />';
});

$view = new SliPHP\View('index');
$view->set('foo', 'value');

<?=$data->foo

$layout = new SliPHP\Layout('default');
$layout->set('foo', 'value');
$layout->body('index');

<?=$data->foo

/var/www/views/index.php (View)
/var/www/views/layouts/default.php (Layout)
/var/www/views/blocks/header.php (Block)