tereta / page
The page content package for the tereta/application framework.It registers html files as pages, reads their metadata from the header comment, and serves the content from a file or from the database.
Requires
- php: >=8.2
- psr/container: ^2.0
- psr/http-message: ^2.0
- psr/http-server-handler: ^1.0
- psr/log: ^3.0
- tereta/application: @dev
- tereta/console: @dev
- tereta/dbal: @dev
- tereta/orm: @dev
- tereta/route: @dev
- tereta/runtime: @dev
- tereta/storage: @dev
Requires (Dev)
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.0
- squizlabs/php_codesniffer: ^3.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
π English | Π ΡΡΡΠΊΠΈΠΉ | Π£ΠΊΡΠ°ΡΠ½ΡΡΠΊΠ°
Page package for the tereta/application framework.
It turns html files into site pages and shows them by their address.
Requirements
PHP 8.2+, tereta/application.
Installation
composer require tereta/application-page
After installation, run the database migration of the application, so the page table is created.
Configuration
Tell the application where the pages of each site live. %s is replaced with the site name:
use Tereta\ApplicationPage\Context\Config as PageConfig;
return [
'page' => (new PageConfig())->set('directory', ROOT_DIRECTORY . '/resources/pages/%s'),
];
For the site base the pages are taken from resources/pages/base/html.
Page file
A page is an html file. At the top of the file there is a comment with the page settings:
<!--
@path /about
@title About us
@description A few words about our company
@css css/about.css
-->
<h1>About us</h1>
<p>We make websites.</p>
@path- the address of the page, it is required.@identifier- the name of the page. If it is not set, the file name is used:about/team.htmlbecomesabout/team.@domain- the domain of the page, if the site has several domains.@cssand@class- styles and css classes for the page. They can be repeated.- Any other tag, like
@title, is passed to the template as is.
Write {site} in the text to insert the address of the site:
<a href="{site}/contacts">Contacts</a>
Register pages
New files must be registered once. Run the command with the site name:
php bin/console.php page:register base
Run it again after you add new files. Pages that already exist are not created twice.
Pictures and styles
Files next to the html folder are available by the address /media/page/<site>/<file>.
For example, resources/pages/base/images/logo.png opens as /media/page/base/images/logo.png.
Supported files: css, js, png, jpg, jpeg, gif, webp, svg.
License
Apache License 2.0