Download the PHP package deathbeam/fwphp without Composer
On this page you can find all versions of the php package deathbeam/fwphp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download deathbeam/fwphp
More information about deathbeam/fwphp
Files in deathbeam/fwphp
Package fwphp
Short Description Blazing fast and simple PHP micro framework
License MIT
Homepage http://deathbeam.github.io/fwphp
Informations about the package fwphp
{ fw.php } code less, create more
- Hello World
- Installation
- Configuration
- Templates
- Routes
- API
- License
Hello World
To create your first hello world fw.php application, create index.php
and add below to it
Installation
Copy this repo into a public accessible folder on your server (or to public_html folder of your FTP if you are using shared hosting). There are muliple ways to get fw.php:
a) download and extract .zip /.tgz by hand
b) cloning the repo with git
c) getting the repo via Composer
Now, we need to install mod_rewrite
becouse it is required for .htaccess
.
Configuration
fw.php can be configured in 2 ways. First one is using only php
and second one is loading configuration from json
file.
In examples below, we will:
- Load
cookie.php
extension fromplugins
folder - Change directory of public files from default
public
tonew_public_dir
- Set
/
route toindex
function
Using php
only
This is basic configuration from index.php
.
Using json
configuration file
Below is example on how to configure fw from .json file
And here is content of config.json
Templates
fw.php have super simple templating system using PHP as templating language.
Drawing template is simple:
Templates can read global variables set by $fw->set
method.
Example template
Below, we will create simple template logic.
Code what will go into routed function in index.php
We will save code below as default.php
to /public
directory
Routes
In fw.php I implemented routing very similar to F3 routing. Features:
- Dynamic routing with named parameters
- Reversed routing
- Flexible regular expression routing
- ReST route mapping
Example routing
API
Name | Usage | Description |
---|---|---|
__set(plugin, value) | $fw->{plugin} = 'file' | Loads specified plugin from plugin directory |
__get(plugin) | $plug = $fw->{plugin} | Gets specified already loaded plugin |
set(key, value) | $fw->set('key', 'value') | Adds specified key to fw.ph stack |
get(key) | $key = $fw->get('key') | Gets specified key from fw.ph stack |
exists(key) | $exists = $fw->exists('key') | Checks if specified key exists |
clear(key) | $fw->clear('key') | Removes specified key from fw.php stack |
stack() | $stack = $fw->stack() | Publish stack contents |
hook(name, callable) | $fw->hook('hook_name') = function() | Adds a new hook to fw.php |
invoke(hook, [opt] args) | $fw->invoke('hook_name') | Invokes specified hook |
config(file) | $fw->config('config.json') | Configure fw.php from json configuration file |
draw(template) | $fw->draw('template.php') | Renders specified template |
route(pattern, callable) | $fw->route('GET /', function()) | Adds route with specified pattern and callback to routing array |
reroute(pattern, [opt] params) | $fw->reroute('/') | Redirects user to specified route |