lausek / lowebf Goto Github PK
View Code? Open in Web Editor NEWlausek's own web framework
Home Page: https://lausek.eu/lowebf
lausek's own web framework
Home Page: https://lausek.eu/lowebf
Idea: Provide functionality for reading and converting superglobal values.
// version 1
$pageId = $env->variables()->get()->getAsInteger("pageId")->unwrapOr(1);
// version 2
$pageId = $env->variables()->get()->asInteger("pageId")->unwrapOr(1);
// version 3
$pageId = $env->variables()->get("pageId")->mapToInteger()->unwrapOr(1);
superglobals
predefined
globals
class VariableModule extends Module {
// $_GET variable
public function get() -> Array;
// $_POST variable
public function post() -> Array;
// $_SERVER variable
public function server() -> Array;
}
class Array {
public static function from(array &$data) : Array;
public function getAsInteger(string $name) : Result<int>;
public function getAsFloat(string $name) : Result<float>;
// ...
}
Cloning the repository takes way too long because of the newly added documentation directory.
Idea: Introduce a new class for wrapping up operation results or errors like a sum type.
Old code:
$env = lowebf\Environment::getInstance();
// will throw an exception
$posts = $env->posts()->loadPage(null);
// ...
New code:
$env = lowebf\Environment::getInstance();
// throws an exception like previous example
$posts = $env->posts()->loadPage(null)->unwrap();
// returns the result if found or exits script if not
$posts = $env->posts()->loadPage(null)->unwrapOrExit($env);
// ...
$env->listDirectory(null)
->mapOk(function ($folders) {
// ... do something with folders ...
return $folders;
});
class Result {
const OK_STATE = 1;
const ERROR_STATE = 2;
/** @var int */
private $state;
private $argument;
private function __construct(int $state, $argument);
public static function ok($value) : Result;
public static function error(Exception $e) : Result;
public function isOk() : bool;
public function isError() : bool;
// try to return operations result.
// throws exception if result is not successful.
public function unwrap();
// unwrap the result or use default
public function unwrapOr($default);
// clear output buffer and set status code
public function unwrapOrExit(Environment $env, $statusCode = null);
// if the result is ok -> pass it to $mapper and wrap it in a new result.
// returns itself otherwise.
public function mapOk(callable $mapper) : Result;
}
Add new method to ConfigModule
for reading nested attributes.
Expected output:
$env->config()->getNested("site.db")
should return ["host": "localhost"]
.$env->config()->getNested("site.db.host")
should return localhost
.site:
db:
host: "localhost"
Requirements:
Concept:
/data/galleries/<year>-<month>-<day>-<title>/...
GalleryModule
load
, loadOrCreate
, loadGalleries
Gallery
$date
$title
$items
(image or video)save
add
, remove
Post
now has an attribute gallery
that stores the associated gallery id.
getGallery() : ?Gallery
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.