2017 © Pedro Peláez
 

library libweb-api

LibWeb API part

image

renanhangai/libweb-api

LibWeb API part

  • Sunday, July 29, 2018
  • by renanhangai
  • Repository
  • 1 Watchers
  • 0 Stars
  • 215 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 25 Versions
  • 46 % Grown

The README.md

libweb\api

Generate REST APIs with ease using slim framework, (*1)

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

Will output, (*2)

{
    "status": "success",
    "data":   "hello world",
}

Methods

  • mapClass( $base, $class ), (*3)

    Ex:, (*4)

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

    Will be mapped to, (*5)

    $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()
    
  • mapPath( $base, $dir, $classTemplate ), (*6)

    Every path will be mapped to a file Ex:, (*7)

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

    When entering to "example.com/test/user/books/data" Will be mapped to, (*8)

    require_once "/project/test/user/Books.php";
    $obj = new \myproject\api\test\user\BooksAPI( $app );
    $obj->GET_data()
    

Request

Inherits from \Slim\Http\Request, (*9)

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

Response

Inherits from \Slim\Http\Response, (*10)

  • withFile( $file, $contentType = null )
  • withString( $buffer, $contentType = null )
  • withDownload( $file, $filename = null, $contentType = null, $mode = "attachment" )
  • withDownloadString( $buffer, $filename, $contentType = null, $mode = "attachment" )
  • withCookie( $key, $value, $options = array() )
  • withCookies( $cookies, $options = array() )
  • withJson( $data, $status = null )
  • withResponse( $data )

The Versions

29/07 2018
11/03 2018
11/03 2018

1.0.1

1.0.1.0

LibWeb API part

  Sources   Download

MIT

The Requires

 

by Avatar renanhangai

15/02 2018

0.5.0

0.5.0.0

LibWeb API part

  Sources   Download

MIT

The Requires

 

by Avatar renanhangai

14/02 2018

0.4.3

0.4.3.0

LibWeb API part

  Sources   Download

MIT

The Requires

 

by Avatar renanhangai

18/12 2017

0.4.2

0.4.2.0

LibWeb API part

  Sources   Download

MIT

The Requires

 

by Avatar renanhangai

07/12 2017

0.4.1

0.4.1.0

LibWeb API part

  Sources   Download

MIT

The Requires

 

by Avatar renanhangai

04/12 2017

0.4.0

0.4.0.0

LibWeb API part

  Sources   Download

MIT

by Avatar renanhangai

04/12 2017

0.3.1

0.3.1.0

LibWeb API part

  Sources   Download

MIT

by Avatar renanhangai

02/12 2017

0.3.0

0.3.0.0

LibWeb API part

  Sources   Download

MIT

by Avatar renanhangai

22/11 2017

0.2.4

0.2.4.0

LibWeb API part

  Sources   Download

MIT

by Avatar renanhangai

22/11 2017

0.2.3

0.2.3.0

LibWeb API part

  Sources   Download

MIT

by Avatar renanhangai

21/11 2017

0.2.2

0.2.2.0

LibWeb API part

  Sources   Download

MIT

by Avatar renanhangai

21/11 2017

v0.2.1

0.2.1.0

LibWeb API part

  Sources   Download

MIT

by Avatar renanhangai

13/11 2017

0.2.0

0.2.0.0

LibWeb API part

  Sources   Download

MIT

by Avatar renanhangai

13/11 2017

0.1.0

0.1.0.0

LibWeb API part

  Sources   Download

MIT

by Avatar renanhangai

13/11 2017

0.0.1

0.0.1.0

LibWeb API part

  Sources   Download

MIT

by Avatar renanhangai