Download the PHP package iamshobe/flight without Composer
On this page you can find all versions of the php package iamshobe/flight. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download iamshobe/flight
More information about iamshobe/flight
Files in iamshobe/flight
Package flight
Short Description Lightweight PHP framework for dispatching and routing
License MIT
Informations about the package flight
Flight - Simplified PHP Framework
This framework is used for simple web navigation. Originally I wanted something similar to Python Django framework but simpler, and I wanted to experience development of a web framework - just for a fun side project.
The first basic dispatcher I came across was https://github.com/noodlehaus/dispatch/blob/master/dispatch.php, but I wanted something a little more complicated (with support of nested uris and regex!), so part of the code is taken from that repo and got wrapped with classes.
How to Install?
in your project:
Documentation
\Flight
class Dispatcher($base_dir, $urls, $use_static=true)
$base_dir - is the directory of the application root. $urls - the root urls array using URL class objects. $use_static - true/false if the app uses static folder.
Dispatcher::dispatch(...$args) - the dispatch method - call at the end of the main file.
- ...$args - arguments to send to all the views.
\Flight\URLS
class URL($regex, $handler, $methods = ["GET", "POST", "PUT", "DELETE", "PATCH"])
$regex - the regex of the uri. $handler - an handler view that will be called. $methods - which methods should the url be active on.
class IncludeURLS($urls)
$urls - the expanded sub urls that should be included from a different location.
\Flight\Views
class View()
View::__invoke($vars) - this method should be overrided by inheriting views. the return value should be a response function that will be activated once the view is on.
static View::response($data, $status_code = 200, $headers = []) - a response function. $data - the data to send $status_code - response status code. $headers - the headers of the response.
View::static_file($path) - serve a static file. $path - the path of the file.
View::page($path, $vars) - render a phtml file. $path - the path of the file. $vars - the vars that should be passed to the template file.
class StaticFile()
static file serve view.
How to Use Example
.htaccess file:
your project working tree:
src/Views/Index.php:
src/Views/File.php:
src/URLS/URLS.php:
index.php:
templates/index.phtml:
Nested URLS
URLS2.php
URLS.php