lausek / lowebf
There is no license information available for the latest version (v0.6.4) of this package.
backend framework for webpages
v0.6.4
2022-06-20 22:12 UTC
Requires
- php: ^7.3
- lausek/scssphp: dev-master
- michelf/php-markdown: 1.8.0
- mustangostang/spyc: 0.6.2
- symfony/filesystem: ^5.3
- twig/twig: ^3.3.2
Requires (Dev)
- badoo/phpcf: 1.0.0rc1
- phan/phan: ^5.1
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2025-03-01 00:28:45 UTC
README
lowebf
is a microframework for creating simple websites.
It provides clean interfaces to separate your site's logic and content.
The lowebf\Environment
class offers modules each solving a specific use case.
Features
- Define site content and configuration in your preferred format (JSON, YAML, Markdown)
- SCSS compiler
- Result type for handling operation outcome
- Markdown extensions for embedding videos by url
Non-Features
- No database connections
- No models
- No routing layer
Modules
Name | Description |
---|---|
Cache | Write files to the site's caching directory |
Config | Access configuration values |
Content | Read a JSON, YAML, or Markdown file |
Download | Send a downloadable file |
Globals | Access php superglobals in a safe manner |
Post | Read a news entry from file |
Route | Generate url for static files |
Thumbnail | Generate thumbnails for images |
View | Render a page template |
Example
composer require lausek/lowebf
composer update
<?php // example implementation of `site/public/index.php`. // your document root should be set to `site/public` to avoid // request escapes into other directories. // this only works if the vendor directory was added to // the include path inside `php.ini`. require "autoload.php"; // create the default instance of our environment $env = lowebf\Environment::getInstance(); // read a value from the php superglobals // passed to your current script. this is equal to: // // $pageNumber = $_GET["p"] ?? 1; // // but it allows you to terminate the program // using `unwrapOrExit($env)` if the variable is not present. $pageNumber = $env->globals()->get("p")->unwrapOr(1); // load a specific post page from your `data/posts` directory. // by default, 15 posts are displayed in one page. // if the page loading fails -> terminate the script and return // a "404 - not found" error. $page = $env->posts()->loadPage($pageNumber)->unwrapOrExit($env, 404); $maxPage = $env->posts()->getMaxPage(); // render the overview with the selected page $env->view()->render("index.html", [ "entries" => $page, "pageCurrent" => $pageNumber, "pageMax" => $maxPage, ] );
Directory structure
cache/
thumbs/
: Thumbnails of poststwig/
: Template caching for Twig
data/
content/
: Miscellaneous content datadownload/
: Files available for downloadmedia/
img/
: Images: png, jpeg, gifvid/
: Videos: mp4, avimisc/
: Other file formats like: pdf, json
posts/
: Frequently updated news in Markdown formatconfig.yaml
: General configuration for the site
site/
css/
:img/
:js/
:public/
: Accessible PHP filesroute.php
: Used for providing all sorts of static files
template/
: Twig template directory
Note: Most directories and files are not required if you do not need them.