phly/phly-simple-page
最新稳定版本:2.0.1
Composer 安装命令:
composer require phly/phly-simple-page
包简介
ZF2 Module for easily creating static pages
README 文档
README
⚠️ Archived 2025-08-17
Use at your own risk.
A Laminas MVC module for "static" pages.
Overview
In most Laminas MVC applications, you'll have at least a few pages that are basically static — the controller contains no logic for the given endpoint, and it simply renders a template.
By default, this requires the following steps:
- Create a route
- Create a controller (if you don't have one already)
- Create an action in that controller
- Create a template
This module halves the workflow by eliminating the middle two steps.
Installation
Use Composer:
$ composer require phly/phly-simple-page
Enable the module
If you are using laminas-component-installer,
you will get prompted to add the module to your config/application.config.php
file.
If you are not, or you choose not to use the component installer, you can enable
it by adding manually it to your config/application.config.php file:
<?php return [ 'modules' => [ 'PhlySimplePage', 'Application', ], ];
Usage
Create configuration in your application, mapping a route to the controller
PhlySimplePage\PageController, and specifying a template key in the route
defaults.
use PhlySimplePage\PageController; return [ 'router' => [ 'routes' => [ 'about' => [ 'type' => 'Literal', 'options' => [ 'route' => '/about', 'defaults' => [ 'controller' => PageController::class, 'template' => 'application/pages/about', // optionally set a specific layout for this page 'layout' => 'layout/some-layout', ], ], ], ], ], ];
Then, make sure you create a template for the page. In the above example, I'd
likely create the file in module/Application/view/application/pages/about.phtml.
Caching
You can enable a write-through cache for all pages served by the
PageController. This is done via the following steps:
- Creating cache configuration
- Enabling the page cache factory
To create cache configuration, create a phly-simple-page configuration key in
your configuration, with a cache subkey, and configuration suitable for
Laminas\Cache\StorageFactory::factory. As an example, the following would setup
filesystem caching:
return [ 'phly-simple-page' => [ 'cache' => [ 'adapter' => [ 'name' => 'filesystem', 'options' => [ 'namespace' => 'pages', 'cache_dir' => getcwd() . '/data/cache', 'dir_permission' => '0777', 'file_permission' => '0666', ], ], ], ], ];
To enable the page cache factory, do the following:
return [ 'service_manager' => [ 'factories' => [ 'PhlySimplePage\PageCache' => \PhlySimplePage\PageCacheFactory::class, ], ], ];
Selectively disabling caching for given routes
If you do not want to cache a specific page/route, you can disable it by
adding the default key do_not_cache with a boolean true value to the route.
As an example:
'about' => [ 'type' => 'Literal', 'options' => [ 'route' => '/about', 'defaults' => [ 'controller' => \PhlySimplePage\PageController::class, 'template' => 'application/pages/about', 'do_not_cache' => true, ], ], ],
Clearing the cache
To clear the cache for any given page, or for all pages, your cache adapter (a) must support cache removal from the command line (APC, ZendServer, and several other adapters do not), and (b) must support flushing if you wish to clear all page caches at once.
The module provides a vendor binary, phly-simple-page for accomplishing this:
-
./vendor/bin/phly-simple-page clear:cachewill clear all cached pages at once. -
./vendor/bin/phly-simple-page clear:cache --page=clear a single cached page; use the template name you used in the routing configuration as the page value.
TODO
- Ability to clear sets of pages
phly/phly-simple-page 适用场景与选型建议
phly/phly-simple-page 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21.06k 次下载、GitHub Stars 达 34, 最近一次更新时间为 2012 年 12 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「module」 「mvc」 「laminas」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phly/phly-simple-page 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phly/phly-simple-page 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phly/phly-simple-page 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Kinikit - PHP Application development framework MVC component
This package provide a Geo modules for yawik.
PSR-11 Aura.DI container configurator for Laminas and Mezzio applications. Drop-in replacement for the archived laminas/laminas-auradi-config with PHP 8.4 and 8.5 support.
MongoDB Adapter to be used with Laminas Paginator
Utils to load, parse and work with configuration on Mezzio projects
bootstrap select field module implementing http://silviomoreto.github.io/bootstrap-select/
统计信息
- 总下载量: 21.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 34
- 点击次数: 21
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: Unknown
- 更新时间: 2012-12-12