PHP code example of toolkit / web-utils
1. Go to this page and download the library: Download toolkit/web-utils 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/ */
toolkit / web-utils example snippets
$renderer = new \Toolkit\Web\ViewRenderer([
'viewsPath' => __DIR__ . '/views',
'layout' => 'my-layout.php',
]);
echo $renderer->render('home/index', ['name' => 'inhere']);
// before call render()
$renderer
// page info
->setPageTitle($title)
->setPageMeta($keywords, $description)
// assets
->addTopCssFile('/assets/libs/highlight/styles/default.css')
->addBottomJsFile([
'/assets/libs/highlight/highlight.pack.js',
'/assets/libs/markdown-it/markdown-it.min.js',
'/assets/src/article/view.js'
]);
/**
* @var \Toolkit\Web\ViewRenderer $this
*/
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="/assets/libs/bootstrap/bootstrap.min.css" rel="stylesheet">
<link href="/assets/src/app.css" rel="stylesheet">
<title><?= $this->getTitle('Hello, world!')
$flash = new Flash();
// a page
$flash->warning('page-msg', 'Please login to operate!');
// an other page
$msg = $flash->get('page-msg');