2017 © Pedro Peláez
 

library express-php

Biblioteca para roteamento (Similar a ExpressJS)

image

carlosroberto555/express-php

Biblioteca para roteamento (Similar a ExpressJS)

  • Saturday, January 13, 2018
  • by CARLOSROBERTO555
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

ExpressPHP

A express like lib for PHP language, (*1)

Installation

You need first to have composer previous installed. You can see more on https://getcomposer.org., (*2)

Now you install this package using:, (*3)

$ composer require carlosroberto555/expressphp

Quick Start

Basic use;, (*4)

<?php
include 'vendor/autoload.php';

$app = new ExpressPHP\Express;

$app->use('/', function ($req, $res) {
  $res->send('Hello world!');
});

Include a children app scope

The new app that includes a children route. The Express app has a static method require, to include a php executable file with actual route scope., (*5)

<?php
include 'vendor/autoload.php';

$app = new ExpressPHP\Express;

$app->use('/api', app::require('/routes/api.php'));

Children route:, (*6)

<?php
// file /routes/api.php
$router = ExpressPHP\Express::Router();

// GET /api/users
$router->get('/users', function ($req, $res) {
  $res->json([
    ['name' => 'Libbie Dunn'],
    ['name' => 'Ella-Mai Davies'],
    ['name' => 'Elsie-Rose Dennis'],
    ['name' => 'Zena Slater'],
    ['name' => 'Antoni Partridge'],
  ]);
});

Include a static content children route

Express has a method called static to include static content. This just send files like images, html, css, js with a cache control header I-Modiffied-Since., (*7)

<?php
include 'vendor/autoload.php';

use ExpressPHP\Express as app;

$app = new app;

$app->use('/hello', app::static('/static/index.html'));
// $app->use('/css', app::static('/static/css'));
// $app->use('/uploads', app::static('/static/images/uploads'));

The html example file:, (*8)

<!DOCTYPE html>
<!-- /static/index.html -->
<html>
  <head>
    <meta charset="utf-8" />
  </head>
  <body>
    <h1>Hello world</h1>
  </body>
</html>

The Versions

13/01 2018

dev-master

9999999-dev

Biblioteca para roteamento (Similar a ExpressJS)

  Sources   Download

MIT

by Carlos Roberto

13/01 2018

v0.0.1

0.0.1.0

Biblioteca para roteamento (Similar a ExpressJS)

  Sources   Download

MIT

by Carlos Roberto