2017 © Pedro Peláez
 

library exphpress

The missing, elegant, productive microframework for PHP, inspired by ExpressJS.

image

odino/exphpress

The missing, elegant, productive microframework for PHP, inspired by ExpressJS.

  • Sunday, July 13, 2014
  • by odino
  • Repository
  • 1 Watchers
  • 6 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Exphpress

Build Status, (*1)

The missing, elegant, productive microframework for PHP, inspired by ExpressJS., (*2)

Because PHP is cool too., (*3)

Example

The very least you need:, (*4)

``` php <?php, (*5)

$app = Exphpress\app();, (*6)

$app->listen(function($req, $res){ $date = new \DateTime();, (*7)

$res->setContent("Today is " . $date->format('l, jS \o\f F Y'));

});, (*8)


This will return, for every request, something like `Today is Sunday, 13th of July 2014,`; if you want to see it in action clone this repository and run `php -S localhost:4000 examples/simple.php`. ## Getting fancy Matching a GET request is quite simple: ``` php <?php $app = Exphpress\app(); $app->get("/call-me-maybe/{name}", function($req, $res){ $res->setContent("Hey, I just matched you, and this is crazy..."); });

The above route will be matched when we issue a GET request to our webserver that matches the path /call-me-maybe/{name}., (*9)

The same can be done for post and all other HTTP methods., (*10)

Write your own middleware

Middlewares play a big part in a microframework's architecture:, (*11)

``` php $app->uses(function($req, $res, $next){ if ($todayIsABadDay) { $res->setStatusCode(403); $res->setContent(null); } else { $next(); } });, (*12)


As you probably understood, the `$next` is a callback that invokes the following middleware, which means that you concatenate them at will (ie. look at [this test](https://github.com/odino/exphpress/blob/6e92cc453185199d2a878ae146b83c395e4bc19c/spec/Exphpress/AppSpec.php#L113-L138)). ## Installation Exphpress is available through [composer](https://packagist.org/packages/odino/exphpress) (how else?!?!). ## Tests They run on travis through phpspec: if you want to contribute or hack around exphpress simply clone this repository and check into greenland with a:

./vendor/bin/phpspec run ```, (*13)

License

For those who care, exphpress is release under the MIT license., (*14)

The hell, why?

There's Silex, I know, but I couldn't resist., (*15)

The Versions

13/07 2014

dev-master

9999999-dev

The missing, elegant, productive microframework for PHP, inspired by ExpressJS.

  Sources   Download

MIT

The Requires

 

The Development Requires

13/07 2014

0.1.1

0.1.1.0

The missing, elegant, productive microframework for PHP, inspired by ExpressJS.

  Sources   Download

MIT

The Requires

 

The Development Requires

13/07 2014

0.1.0

0.1.0.0

The missing, elegant, productive microframework for PHP, inspired by ExpressJS.

  Sources   Download

MIT

The Requires

 

The Development Requires