1. Go to this page and download the library: Download renanhangai/libweb 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/ */
renanhangai / libweb example snippets
use LibWeb\Validator as v;
use LibWeb\DB;
class TestAPI {
public function GET_multiply( $req ) {
$data = $req->params(array(
"a" => v::f(),
"b" => v::f(),
));
return $data->a * $data->b;
}
public function POST_create( $req ) {
$data = $req->params(array(
"name" => v::s(),
"age" => v::i(),
));
$id = DB::insertInto( "person", $data ); // "INSERT INTO person (name, age) VALUES (:name, :age)"
return $id;
}
public function POST_update( $req ) {
$data = $req->params(array(
"id" => v::i(),
"age" => v::i(),
));
$query = "UPDATE person SET age=:age WHERE id=:id"
$result = DB::execute( $query, $data );
}
};
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.