Download the PHP package settermjd/laminas-static-pages without Composer
On this page you can find all versions of the php package settermjd/laminas-static-pages. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download settermjd/laminas-static-pages
More information about settermjd/laminas-static-pages
Files in settermjd/laminas-static-pages
Package laminas-static-pages
Short Description An easy, almost painless, way to render static pages in Zend Expressive applications.
License BSD-3-Clause
Informations about the package laminas-static-pages
Laminas Static Pages Module
An, almost, painless way to render static pages in Mezzio applications.
Note: This module does not support laminas-mvc applications.
The intent of this package is to avoid the necessity to create handlers and handler factories just to render static content. It was motivated by various projects that I've worked on, where that seemed to be the case, at least at the time. That approach never made sense to me, so that's that motivated me to scratch my own itch.
Getting Started
To install the package, run composer require settermjd/laminas-static-pages
.
If you want to automate the enabling of the module when running composer require/install/update
, then your project needs to use laminas/laminas-component-installer.
If it does, when the package is installed you'll be asked if you want to enable its ConfigProvider.
Answer with Y
and the package will be ready to use.
If you don't use laminas-component-installer
, or for some reason or other can't, then ensure that \StaticPages\ConfigProvider::class,
is in the ConfigAggregator
list in config/config.php
, as in the example below.
With the package installed, you now need to do two further steps:
- Configure the template path
- Create routes
- Create template files
Configure The Template Path
To configure the template path, ensure that in your template paths list, there's one with the key static-pages
, as in the example below.
Create Routes
To create a route for a static page, in your routing table, add one or more named routes where:
- The route’s handler is
StaticPagesHandler::class
- The name follows the convention:
static.<template_file_name_minus_file_extension>
.
Let's assume that we are adding a route for a privacy page and that the template file which will be rendered is privacy.phtml
.
In that case we'd add the following to config/routes.php
:
Create Template Files
The file can contain whatever you like, it doesn't matter.
That’s It
All being well, this should be all that you need to rapidly serve static content files in your Mezzio applications.
Support
All versions of laminas-static-pages with dependencies
laminas/laminas-config-aggregator Version ^1.6.0
laminas/laminas-diactoros Version ^2.8.0
mezzio/mezzio Version ^3.6.0
laminas/laminas-stdlib Version ^3.6.0