定制 zfmastery/ze-static-pages 二次开发

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

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

zfmastery/ze-static-pages

Composer 安装命令:

composer require zfmastery/ze-static-pages

包简介

An easy, almost painless, way to render static pages in Zend Expressive applications.

README 文档

README

An easy, almost painless, way to render static pages in Zend Expressive applications.

So many projects will have a number of static pages, pages that require no template variable interpolation or any other form of logic. Given that it should be as simple as possible to just render as many as you need with a minimum of fuss and effort. However, by default, you have to either code this yourself; worse case scenario, you may end up creating loads of code, just to render static content. The intent of the module is to take all that effort away. All you need to do is:

  • Create the content itself
  • Organise the files as best you see fit in the template directory
  • Create routes which link to the respective templates

At this stage, the project is still under heavy development. So there are no further instructions. But, they will follow shortly.

How it Works

This module aims to make organising and rendering static content as simple as possible. It does so by using the route's name to determine the template to render. In the example below, you can see that it defines a new route, called /disclosure. The route uses StaticPagesAction::class as the handling middleware and has the name static.disclosure.

$app->get('/disclosure', \StaticPages\Action\StaticPagesAction::class, 'static.disclosure');

The name is important, as it infers the name of the template which StaticPagesAction will attempt to render. Specifically, it will attempt to render disclosure.phtml. So you can see that the route’s name is the template’s name, minus the .phtml extension, and prefixed with static..

At this point, as the module’s quite new, the template directory that is searched, templates/static-pages, is fixed, and all templates need to be in the top-level of that directory. What’s more, it’s not been tested with other template rendering engines. However, these are expected to change in an upcoming release.

Getting Started / Installing

To install the module, use Composer by running composer require zfmastery/ze-static-pages. The current release doesn't support automatic creation of the required module configuration file, nor of the template directory. That is planned for a future release however.

Given that:

  1. Copy the default config file config/static-pages.global.php to your Zend Expressive's config/autoload/ directory.
  2. In the root directory, create the directory structure templates/static-pages/ and in there create your static templates files.
  3. Add routes to use your new static templates.

Running the Tests

To run the unit tests, run composer test.

统计信息

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

GitHub 信息

  • Stars: 6
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2017-07-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固