定制 carlosroberto555/expressphp 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

carlosroberto555/expressphp

Composer 安装命令:

composer require carlosroberto555/expressphp

包简介

Biblioteca para roteamento (Similar a ExpressJS)

README 文档

README

A express like lib for PHP language

Installation

You need first to have composer previous installed. You can see more on https://getcomposer.org.

Now you install this package using:

$ composer require carlosroberto555/expressphp

Quick Start

Basic use;

<?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.

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

$app = new ExpressPHP\Express;

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

Children route:

<?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.

<?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:

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

统计信息

  • 总下载量: 124
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-02-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固