PHP code example of renanhangai / libweb-api

1. Go to this page and download the library: Download renanhangai/libweb-api 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-api example snippets



$app = new \libweb\api\App;
$app->get( "/", function() { return "hello world"; });
$app->run();

	$app->mapClass( "/test", "\\test\\api\\Test" );
	

	$obj = new \test\api\Test( $app );

	// "example.com/test/data"
	$obj->GET_data()

	// "example.com/test/info-name"
	$obj->GET_infoName()

	// "example.com/test/sub/dir/data"
	$obj->GET_sub_dir_data()

	// "example.com/test/sub-info/dir-name/data-user"
	$obj->GET_subInfo_dirName_dataUser()
	

	$app->mapPath( "/test", "/project/test/", "\\myproject\\api\\test{path}{class}API" );
	

		$obj = new \myproject\api\test\user\BooksAPI( $app );
	$obj->GET_data()
	

   $data = $req->getValidatedParams([
        "name" => v::s(),
        "list" => v::arrayOf([
            "id" => v::i(),
            "level?" => v::set(["N","R","W"]),
        ]),
    ]);