定制 greg-md/php-view 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

greg-md/php-view

Composer 安装命令:

composer require greg-md/php-view

包简介

A powerful View for PHP.

README 文档

README

StyleCI Build Status Total Downloads Latest Stable Version Latest Unstable Version License

A powerful View for PHP.

Table of Contents:

Requirements

  • PHP Version ^7.1

Compilers

  • PHP
  • Blade

How It Works

First of all, you have to initialize a Viewer:

$viewsDirectory = __DIR__ . '/views';

$viewer = new \Greg\View\Viewer($viewsDirectory);

Optionally, you can add a view compiler. For example a Blade Compiler specially created for the Viewer:

// Turn it to a callable, to load only when using blade templates.
$viewer->addExtension('.blade.php', function () {
    $compiledViewsDirectory = __DIR__ . '/compiled';

    return new \Greg\View\ViewBladeCompiler($compiledViewsDirectory);
});

By default it will use Renderer as an instance of a template.

Note: If you want to use your own compiler, it has to be an instance of Compiler Strategy.

Now, you can render views where you want in your application.

Create a template file in the views directory. For example welcome.blade.php:

<html>
    <body>
        <h1>Hello, {{ $name }}</h1>
    </body>
</html>

Use welcome template in your application:

$content = $viewer->render('welcome', [
    'name' => 'Greg',
]);

echo $content;

Documentation

License

MIT © Grigorii Duca

Huuuge Quote

I fear not the man who has practiced 10,000 programming languages once, but I fear the man who has practiced one programming language 10,000 times. #horrorsquad

统计信息

  • 总下载量: 203
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固