Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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)**