Download the PHP package jyoungblood/xprss without Composer
On this page you can find all versions of the php package jyoungblood/xprss. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jyoungblood/xprss
More information about jyoungblood/xprss
Files in jyoungblood/xprss
Package xprss
Short Description Fast, unopinionated, minimalist web framework for PHP
License MIT
Informations about the package xprss
XPRSS — A fast, unopinionated, minimalist web framework for PHP.
This is almost a direct clone of express-php, which tries to clone the NodeJS ExpressJS framework writing style. It does not have an event loop, it just mimics the method and helpers names that ExpressJS offers.
Install
Requirements: PHP >= 7.0 and Apache.
Then, copy the .htaccess to the root of your site:
(if you don't want to copy, put this in a new .htaccess file)
(you can also do it for nginx)
Usage / DEMO example init
here's a quick example of how to initialize. if you're interested in more boilerplate check out [the docs] for more options and also the [index.php file in the app] contains a full example and also also [create-xprss-app] for a reasonable boilerplate starter kit thing
Routes
Routes are handled using a Router instance, for example:
You can handle post requests as well using post() instead of get(). Same for put() and delete().
Route with dynamic parameters
You can route dynamic URL using parameters, for example:
Responses
If you're developing an API for example, you can send json simply doing:
You can also send a custom http response code using:
TIP: There are a few more examples in the index.php
file in this repository.
Static files
If you wish to serve static files (likes images, html only) you can use:
Template engines
You're on your own for templating...at some point we'll have a guide for how to support various template engines (jade/pug, handlebars, twig, etc)
We'd like to to be as easy as:
Request info
- body of the request: $res->body
- query string: $req->query
- cookies: $req->cookies
- all the request headers: $req->headers