Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/php-toolkit/web-utils
some library for php web application
https://github.com/php-toolkit/web-utils
flash-messages view-renderer
Last synced: 22 days ago
JSON representation
some library for php web application
- Host: GitHub
- URL: https://github.com/php-toolkit/web-utils
- Owner: php-toolkit
- License: mit
- Created: 2017-12-11T14:25:59.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-15T06:48:48.000Z (over 6 years ago)
- Last Synced: 2024-11-29T14:56:07.188Z (about 2 months ago)
- Topics: flash-messages, view-renderer
- Language: PHP
- Size: 40 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# php web tools
- a simple php view renderer, front assets load manage
- url,html,curl helper class## Usage
### View renderer
- support layout, data render
- support simple assets manage and load
- support include other file in a view file```php
$renderer = new \Toolkit\Web\ViewRenderer([
'viewsPath' => __DIR__ . '/views',
'layout' => 'my-layout.php',
]);echo $renderer->render('home/index', ['name' => 'inhere']);
```- setting page attrs and add assets
```php
// 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'
]);
```- in view template file.
```php
/**
* @var \Toolkit\Web\ViewRenderer $this
*/
= $this->getTitle('Hello, world!') ?>
dumpTopAssets() ?>include('_layouts/common-header'); ?>
{__CONTENT__}
sadebar .... my name is: = $name ?>
include('_layouts/common-footer'); ?>
dumpBottomAssets() ?>
```
### Flash Messages
```php
$flash = new Flash();// a page
$flash->warning('page-msg', 'Please login to operate!');// an other page
$msg = $flash->get('page-msg');
```## license
**[MIT](LICENSE)**