exssah/exss 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

exssah/exss

最新稳定版本:0.1.0

Composer 安装命令:

composer require exssah/exss

包简介

This is a library for creating an asynchronous HTTP server using PHP.

README 文档

README

Exss is a library for creating an asynchronous HTTP server using PHP. It is built on top of the ReactPHP framework. With this library, you can create your asynchronous web app using PHP, and it is similar to Express.js.

Installation

Use the package manager Composer to install Exss.

composer require exssah/exss

Usage

Basic http server

require __DIR__ . '/vendor/autoload.php';

use Exssah\Exss\Exss;
use Exssah\Exss\Req;
use Exssah\Exss\Res;

# create a object of Exss class
$app = new Exss();

# use route methods to accept asynchronous HTTP requests
$app::get('/hello', function(Req $req, Res $res){
  return $res::send('Hello world');
});

# start the server at port 8080
$app::listen(8080, function(){
    echo 'http://localhost:8080';
});

Accept The Request Parameters
ex:- http://localhost:8080/user?id=5&name=Somnath Gupta

require __DIR__ . '/vendor/autoload.php';

use Exssah\Exss\Exss;
use Exssah\Exss\Req;
use Exssah\Exss\Res;

# create a object of Exss class
$app = new Exss();

# use route methods to accept asynchronous HTTP requests
#ex:- http://localhost:8080/user?id=5&name=Somnath Gupta

$app::get('/user', function(Req $req, Res $res){

  $userID = $req::params('id'); #'null' if not exist
  $userName = $req::params('name'); #'null' if not exist

 #use the sendJson method to send a JSON response
  return $res::sendJson([
    'id' => $userID,
    'name' => $userName,
  ]);

});

# start the server at port 8080
$app::listen(8080, function(){
    echo 'http://localhost:8080';
});

Accept The Request Body

URl:- http://localhost:8080/user

Body
{
"username" : "Somnath Gupta",
"gmail" : "testgmail@gmail.com",
"password" : "U7%)#",
}

require __DIR__ . '/vendor/autoload.php';

use Exssah\Exss\Exss;
use Exssah\Exss\Req;
use Exssah\Exss\Res;

# create a object of Exss class
$app = new Exss();

# use route methods to accept asynchronous HTTP requests

$app::post('/user', function(Req $req, Res $res){

  $username = $req::body('username'); #'null' if not exist
  $gmail = $req::body('gmail'); #'null' if not exist
  $password = $req::body('password'); #'null' if not exist

 #use the sendJson method to send a JSON response
  return $res::sendJson([
    'username' => $username,
    'gmail' => $gmail,
    'password' => $password,
  ]);

});

# start the server at port 8080
$app::listen(8080, function(){
    echo 'http://localhost:8080';
});

Your can use other fetchers of ReactPHP framework

1) Promise , 2) Async Utilities, 3) Browser Api's

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Step 1: Download, install, and configure PHP and Composer to your local computer.

Step 2: Now Fork a repo

Step 3: Download the code to your local machine

Step 4: Open the folder 'Exss'

Step 5: Open Terminal

Step 6: Run this command to download all the necessary dependencies.

composer install

Step 7: If you don't know about ReactPHP framework then you can visit there

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-09