1. Go to this page and download the library: Download exssah/exss library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
exssah / exss example snippets
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';
});
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';
});
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';
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.