public function populate(Restler $restler)
 {
     $restler->addAPIClass('\\Tuleap\\Project\\REST\\ProjectResource', ProjectRepresentation::ROUTE);
     $restler->addAPIClass('\\Tuleap\\Token\\REST\\TokenResource', TokenRepresentation::ROUTE);
     $restler->addAPIClass('\\Tuleap\\Project\\REST\\UserGroupResource', UserGroupRepresentation::ROUTE);
     $restler->addAPIClass('\\Tuleap\\User\\REST\\UserResource', UserRepresentation::ROUTE);
     $restler->addAPIClass('\\Tuleap\\User\\REST\\v1\\UserMembershipResource', UserMembershipRepresentation::ROUTE);
     $restler->addAPIClass('\\Tuleap\\PhpWiki\\REST\\v1\\PhpWikiResource', PhpWikiPageRepresentation::ROUTE);
     $restler->addAPIClass('\\Tuleap\\JWT\\REST\\v1\\JWTResource', JWTRepresentation::ROUTE);
 }
<?php

/**
 * Created by PhpStorm.
 * User: MartinTiefengrabner
 * Date: 20/08/15
 * Time: 10:20
 */
require_once '../doc/vendor/restler.php';
use Luracast\Restler\Restler;
use Luracast\Restler\Defaults;
//set the defaults to match your requirements
Defaults::$throttle = 20;
//time in milliseconds for bandwidth throttling
//setup restler
$r = new Restler();
$r->addAPIClass('YourApiClassNameHere');
// repeat for more
$r->addAPIClass('Resources');
//from restler framework for API Explorer
$r->addFilterClass('RateLimit');
//Add Filters as needed
$r->handle();
//serve the response
Esempio n. 3
0
3. Add `@access protected` comment to the class to protect all methods of that
   class


In order to provide access to those protected methods we use a class that
implements `iAuthenticate`. Also note that An Authentication class is also an
API class so all public methods that does not begin with `_` will be exposed as
API for example [SimpleAuth::key](simpleauth/key). It can be used to create
login/logout methods.

Example 1: GET restricted returns

{
  "error": {
    "code": 401,
    "message": "Unauthorized"
  }
}

 Example 2: GET restricted?key=rEsTlEr2 returns "protected method"

 Example 3: GET secured?key=rEsTlEr2 returns "protected class"
*/
require_once '../../../vendor/restler.php';
use Luracast\Restler\Restler;
$r = new Restler();
$r->addAPIClass('Simple', '');
//map it to root
$r->addAPIClass('Secured');
$r->addAuthenticationClass('SimpleAuth');
$r->handle();
Esempio n. 4
0
<?php

/*
 * Testing all the attributes for @param annotation
 */
use Luracast\Restler\Restler;
use Luracast\Restler\Defaults;
require_once "../../../vendor/restler.php";
Defaults::$crossOriginResourceSharing = true;
$r = new Restler();
$r->addAPIClass('MinMax');
$r->addAPIClass('MinMaxFix');
$r->addAPIClass('Type');
$r->addAPIClass('Validation');
//$r->addAPIClass('Resources');
$r->addAPIClass('Explorer', 'swagger');
$r->handle();
Esempio n. 5
0
> **Note:-**
>
>  1. Using session variables as DB and Cache is useless for real life and wrong. We are using it
>     Only for demo purpose. Since API Explorer is browser based it works well with that.
>
>  2. We are using Author.php to document return type of `GET authors/{id}` using `@return` comment

If you have hit the API Rate Limit or screwed up the Authors DB, you can easily reset by deleting
PHP_SESSION cookie using the Developer Tools in your browser.

Helpers: Author

Footer:
*[Author.php]: _009_rate_limiting/Author.php
*/
use Luracast\Restler\Defaults;
use Luracast\Restler\Filter\RateLimit;
use Luracast\Restler\Restler;
require_once '../../../vendor/restler.php';
//reuse the SessionDB from CRUD Example
require_once '../_007_crud/DB/Session.php';
//used only for demo, comment the following line
Defaults::$cacheClass = 'SessionCache';
//set extreme value for quick testing
RateLimit::setLimit('hour', 10);
$r = new Restler();
$r->addAPIClass('ratelimited\\Authors');
$r->addAPIClass('Resources');
$r->addFilterClass('RateLimit');
$r->addAuthenticationClass('KeyAuth');
$r->handle();
Esempio n. 6
0
    @view  folder/name.extension
When the extension is omitted `HtmlFormat::$format` will be used
HtmlFormat will look at `views` folder that resides parallel to `vendor` directory
for the template files and can be changed by setting `HtmlFormat::$viewPath` to
full path of a folder
Content:
In this example, we are building tasks api and also a single page application
using jQuery and the templates
[![Single Page App](../resources/html_view.png)](tasks)
Our api response is sent to the template under the name `response` along with other
information such as `basePath`, `baseUrl`, `request` parameters.
You can send custom data yourself by setting key value pairs in
`HtmlFormat::$data` array
If you do not want all the information and want to keep your template simple, you
can use `{@data key.innerkey}` comment as shown below
    @view todo/list {@data response}
This calls the list template with key value pairs defined at the response array
directly accessible as the variable and value inside the template
This example also show cases the heredoc syntax based simple templating system
which is Supported with out any external dependencies
Just to show that it is possible to come up with API as well as an App using the
same resource and url, you can try the json version of the tasks api using the
API Explorer [here](explorer/index.html)
*/
require_once '../../../vendor/restler.php';
use Luracast\Restler\Restler;
$r = new Restler();
$r->setSupportedFormats('JsonFormat', 'HtmlFormat');
$r->addAPIClass('Tasks');
$r->addAPIClass('Resources');
$r->handle();
Esempio n. 7
0
<?php

require_once '../bootstrap.php';
require_once 'SimpleAuth.php';
use Luracast\Restler\Resources;
Resources::$useFormatAsExtension = false;
use Luracast\Restler\Restler;
$r = new Restler(true, true);
$r->addAPIClass('Luracast\\Restler\\Resources');
$r->setSupportedFormats('JsonFormat');
$r->addAuthenticationClass('SimpleAuth');
$r->addAPIClass('User');
$r->addAPIClass('Book');
$r->addAPIClass('Car');
$r->addAPIClass('Ads');
$r->addAPIClass('Clicks');
$r->addAPIClass('Points');
$r->addAPIClass('Plan');
$r->addAPIClass('Mvnos');
$r->addAPIClass('Subscribers');
$r->addAPIClass('Mvno');
$r->addAPIClass('Impression');
$r->handle();
Esempio n. 8
0
Example 3: GET v2/bmi?height=190 returns
{
  "error": {
    "code": 400,
    "message": "Bad Request: invalid height unit"
  }
}
Example 4: GET v2/bmi?height=162cm returns
{
  "bmi": 23.27,
  "message": "Normal weight",
  "metric": {
    "height": "190 centimeters",
    "weight": "84 kilograms"
  },
  "imperial": {
    "height": "6 feet 2 inches",
    "weight": "185.19 pounds"
  }
}
Content:
*/
require_once '../../../vendor/restler.php';
use Luracast\Restler\Defaults;
use Luracast\Restler\Restler;
Defaults::$useUrlBasedVersioning = true;
$r = new Restler();
$r->setAPIVersion(2);
$r->addAPIClass('BMI');
$r->addAPIClass('Explorer');
$r->handle();
Esempio n. 9
0
[Restler API Explorer](https://github.com/Luracast/Restler-API-Explorer)
which is used [here](explorer/index.html#!/authors-v1).

[![Restler API Explorer](../resources/explorer1.png)](explorer/index.html#!/authors-v1)

We are progressively improving the Authors class from CRUD example 
to Rate Limiting Example to show Best Practices and Restler 3 Features.

Make sure you compare them to understand.

Even though API Explorer is created with API consumers in mind, it will help the
API developer with routing information and commenting assistance when  our API
class is not fully commented as in this example. This works only on the debug
mode. Try changing rester to run in production mode (`$r = new Restler(true)`)

> **Note:-** production mode writes human readable cache file for the routes in
> the cache directory by default. So make sure cache folder has necessary
> write permission.

Happy Exploring! :)
*/
require_once '../../../vendor/restler.php';
//reuse the SessionDB from CRUD Example
require_once '../_007_crud/DB/Session.php';
use Luracast\Restler\Restler;
$r = new Restler();
// comment the line above and uncomment the line below for production mode
// $r = new Restler(true);
$r->addAPIClass('improved\\Authors');
$r->addAPIClass('Resources');
$r->handle();
Esempio n. 10
0
<?php

error_reporting(0);
header('Content-Type: application/json; charset=utf-8');
require 'vendor/autoload.php';
require 'PortalTransparencia.php';
use Luracast\Restler\Restler;
$rest = new Restler();
$rest->addAPIClass('PortalTransparencia');
$rest->handle();
Esempio n. 11
0
 */
require_once 'vendor/restler.php';
use Luracast\Restler\Restler;
use Luracast\Restler\Responder;
use Luracast\Restler\Defaults;
/*
 * There was a need for more complex validation return messages. this showed the way:
 * http://stackoverflow.com/questions/13107318/how-can-i-return-a-data-object-when-throwing-a-restexception
 * In a nutshell, extend the Responder class (that restler uses for giving a structure to the error and success response)
 * like below:
 */
class MyResponder extends Responder
{
    public static $data = null;
    public function formatError($statusCode, $message)
    {
        $r = array('error' => array('code' => $statusCode, 'message' => $message));
        if (isset(self::$data)) {
            $r['data'] = self::$data;
        }
        return $r;
    }
}
Defaults::$responderClass = 'MyResponder';
require_once 'pbo/property.php';
// Restler setup. See the following for details: http://restler3.phpfogapp.com/examples/
$r = new Restler();
$r->addAPIClass('Luracast\\Restler\\Resources');
//this creates resources.json at API Root
$r->addAPIClass('Property');
$r->handle();
Esempio n. 12
0
<?php

/*
Title: Hello World Example
Tagline: Let's say hello!
Tags: basic
Requires: PHP >= 5.3
Description: Basic hello world example to get started with Restler 3.
Example 1: GET say/hello returns "Hello world!"
Example 2: GET say/hello?to=R.Arul%20Kumaran returns "Hello R.Arul Kumaran!"
Example 3: GET say/hi?to=restler3.0 returns "Hi restler3.0!"
Content: > **Note:-** If you have used Restler 2 before, you will wonder why
the generated routes are lesser with Restler 3.
Look at [Routes](../_006_routing/readme.html) example to understand.
*/
require_once '../../../vendor/restler.php';
use Luracast\Restler\Restler;
$r = new Restler();
$r->addAPIClass('Say');
$r->handle();
Esempio n. 13
0
  <metric>
    <height>162.6 centimeter</height>
    <weight>84 kilograms</weight>
  </metric>
  <imperial>
    <height>5 feet 4 inches</height>
    <weight>185.19 pounds</weight>
  </imperial>
</response>

 Example 3: GET bmi.json returns

 {
  "bmi": 31.77,
  "message": "Obesity",
  "metric": {
    "height": "162.6 centimeter",
    "weight": "84 kilograms"
  },
  "imperial": {
    "height": "5 feet 4 inches",
    "weight": "185.19 pounds"
  }
}
*/
require_once '../../../vendor/restler.php';
use Luracast\Restler\Restler;
$r = new Restler();
$r->setSupportedFormats('JsonFormat', 'XmlFormat');
$r->addAPIClass('BMI');
$r->handle();
Esempio n. 14
0
###Authentication###
Once the proper authorization has been attained by the client app, it's sole responsibility is to pass along it's 
authorization status in each RESTful API request. This is achieved by the client application adding a *query parameter* of 
'code' set to the access token that the OAuth Server provided to the application in the authorization step. 

> **Note:-**
> there is an optional parameter on the server that allows the Access Token to be passed as a header variable instead of a
> query parameter.

## In Conclusion ##
The "client application" plays an important role in the OAuth interaction and while your Restler server's primarily role will
likely be to play the *server* role in this process it is useful to know that both client and server are available as part of
the [OAuth 2.0 Server ](http://bshaffer.github.io/oauth2-server-php-docs/) module and both are easily made available to Restler. 

For more information on how to start using this functionality with Restler be sure to look at the [OAuth Server example](../_015_oauth2_server/index.php).
*/
require_once '../../../vendor/restler.php';
use Luracast\Restler\Restler;
use Auth\Client;
//This client talks to the server in the next folder, you can change it by un commenting and customizing the following
//Client::$serverUrl = 'http://brentertainment.com/oauth2/lockdin';
//Client::$authorizeRoute = 'authorize';
//Client::$tokenRoute = 'token';
//Client::$resourceMethod = 'GET';
//Client::$resourceRoute = 'resource';
//Client::$resourceParams = array();
//Client::$resourceOptions = array(); //curl options
$r = new Restler();
$r->addAPIClass('Auth\\Client', '');
$r->setOverridingFormats('HtmlFormat', 'UploadFormat', 'JsonFormat');
$r->handle();
Esempio n. 15
0
/////////////////////// PHPMailer Section
require_once 'vendor/PHPMailer/PHPMailerAutoload.php';
/////////////////////// Database Section - https://github.com/ajaxray/static-pdo
require_once 'vendor/SimplePDO/Db.php';
Db::setConnectionInfo(DBNAME, DBUSER, DBPASS, DBTYPE, DBHOST);
Db::execute('SET CHARACTER SET utf8');
/////////////////////// Static class for TooTutor Online
require_once 'vendor/TooTutor/TTO.php';
require_once 'vendor/TooTutor/TTOMail.php';
/////////////////////// Restler Section
require_once 'vendor/restler.php';
use Luracast\Restler\Restler;
Defaults::$crossOriginResourceSharing = true;
Defaults::$accessControlAllowOrigin = '*';
$r = new Restler();
$r->addAPIClass('Conversion');
$r->addAPIClass('Test');
$r->addAPIClass('Explorer');
//$r->setAPIVersion(1);
$r->addAuthenticationClass('Auth');
$r->addAPIClass('App');
$r->addAPIClass('User');
$r->addAPIClass('Bank');
$r->addAPIClass('Coin');
$r->addAPIClass('Order');
$r->addAPIClass('Category');
$r->addAPIClass('Course');
$r->addAPIClass('CourseSection');
$r->addAPIClass('Section');
$r->addAPIClass('Task');
$r->addAPIClass('Item');
Esempio n. 16
0
<?php

error_reporting(0);
header('Content-Type: application/json; charset=utf-8');
require 'vendor/autoload.php';
require 'Estafeta.php';
use Luracast\Restler\Restler;
$rest = new Restler();
$rest->addAPIClass('Estafeta');
$rest->handle();
Esempio n. 17
0
<?php

/*
 * Testing all the attributes for @param annotation
 */
use Luracast\Restler\Restler;
use Luracast\Restler\Defaults;
require_once "../../../vendor/restler.php";
Defaults::$crossOriginResourceSharing = true;
$r = new Restler();
$r->addAPIClass('MinMax');
$r->addAPIClass('MinMaxFix');
$r->addAPIClass('Type');
$r->addAPIClass('Validation');
$r->addAPIClass('Resources');
$r->handle();
Esempio n. 18
0
Cookie: PHPSESSID=dcdfec433e86c1a6730f75303187071f
{"name":"Another","email":"*****@*****.**"}
```
and the response for all the above could be
```http
HTTP/1.1 200 OK
Date: Tue, 25 Sep 2012 10:05:06 GMT
Server: Apache/2.2.19 (Unix) mod_ssl/2.2.19 OpenSSL/0.9.8r DAV/2 PHP/5.3.6 with Suhosin-Patch
X-Powered-By: Luracast Restler v3.0.0
Expires: 0
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
Content-Length: 66
Content-Type: application/json
{
  "name": "Another",
  "email": "*****@*****.**",
  "id": 7
}
```
 Helpers: DB\Session
 Content:
*[MySQL.php]: _007_crud/DB/PDO/MySQL.php
*[Sqlite.php]: _007_crud/DB/PDO/Sqlite.php
*[SerializedFile.php]: _007_crud/DB/SerializedFile.php
*/
require_once '../../../vendor/restler.php';
use Luracast\Restler\Restler;
$r = new Restler();
$r->addAPIClass('Authors');
$r->handle();
Esempio n. 19
0
<?php

/*
Title: Access Control
Tagline: Who can do what
Tags: access-control, acl, secure, authentication, authorization
Requires: PHP >= 5.3
Description:
This example shows how you can extend the authentication system to create
a robust access control system. As a added bonus we also restrict api
documentation based on the same.

When the `api_key` is

- blank you will see the public api
- `12345` you will see the api that is accessible by an user
- `67890` you will see all api as you have the admin rights

Try it out yourself [here](explorer/index.html#!/v1)
*/
require_once '../../../vendor/restler.php';
use Luracast\Restler\Restler;
$r = new Restler();
$r->addAPIClass('Access', '');
$r->addAPIClass('Resources');
$r->addAuthenticationClass('AccessControl');
$r->handle();
Esempio n. 20
0
<?php

require_once 'vendor/restler.php';
require_once 'classes/Transaction.php';
use Luracast\Restler\Restler;
//remove .json from urls of all service methods
Resources::$placeFormatExtensionBeforeDynamicParts = false;
$r = new Restler();
$r->refreshCache();
$r->setSupportedFormats('JsonFormat');
$r->addAPIClass('Transactionservice');
$r->addApiClass('Resources');
//this produces the needed resources.json
$r->handle();
Esempio n. 21
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
$loader = (require_once 'restler/vendor/autoload.php');
$loader->setUseIncludePath(true);
use Luracast\Restler\Restler;
$r = new Restler();
$r->addAPIClass('Say');
// repeat for more
$r->addAPIClass('Check');
// repeat for more
$r->handle();
//serve the response
Esempio n. 22
0
<?php

use Luracast\Restler\Restler;
require __DIR__ . '/../vendor/autoload.php';
$r = new Restler();
$r->addAPIClass('Home', '');
$r->addAPIClass('Explorer');
$r->handle();
Esempio n. 23
0
>  1. Using session variables as DB and Cache is useless for real life and wrong. We are using it
>     Only for demo purpose. Since API Explorer is browser based it works well with that.
>
>  2. We are using Author.php to document return type of `GET authors/{id}` using `@return` comment

If you have hit the API Rate Limit or screwed up the Authors DB, you can easily reset by deleting
PHP_SESSION cookie using the Developer Tools in your browser.

Helpers: Author

Footer:
*[Author.php]: _009_rate_limiting/Author.php
*/
use Luracast\Restler\Defaults;
use Luracast\Restler\Explorer;
use Luracast\Restler\Filter\RateLimit;
use Luracast\Restler\Restler;
require_once '../../../vendor/restler.php';
//reuse the SessionDB from CRUD Example
require_once '../_007_crud/DB/Session.php';
//used only for demo, comment the following line
Defaults::$cacheClass = 'SessionCache';
//set extreme value for quick testing
RateLimit::setLimit('hour', 10);
Explorer::$hideProtected = false;
$r = new Restler();
$r->addAPIClass('ratelimited\\Authors');
$r->addAPIClass('Explorer');
$r->addFilterClass('RateLimit');
$r->addAuthenticationClass('KeyAuth');
$r->handle();
Esempio n. 24
0
API developer with routing information and commenting assistance when  our API
class is not fully commented as in this example. This works only on the debug
mode. Try changing rester to run in production mode (`$r = new Restler(true)`)

> **Note:-** production mode writes human readable cache file for the routes in
> the cache directory by default. So make sure cache folder has necessary
> write permission.

Happy Exploring! :)
*/
require_once 'vendor/restler.php';
use Luracast\Restler\Restler;
$r = new Restler();
// comment the line above and uncomment the line below for production mode
// $r = new Restler(true);
$r->addAPIClass('generator\\Constructor');
$r->addAPIClass('generator\\Generator');
$r->addAPIClass('noob\\sycon\\Authentication');
$r->addAPIClass('noob\\sycon\\Bill');
$r->addAPIClass('noob\\sycon\\Cashier');
$r->addAPIClass('noob\\sycon\\Category');
$r->addAPIClass('noob\\sycon\\Client');
$r->addAPIClass('noob\\sycon\\CommandProduct');
$r->addAPIClass('noob\\sycon\\Commands');
$r->addAPIClass('noob\\sycon\\Customer');
$r->addAPIClass('noob\\sycon\\History');
$r->addAPIClass('noob\\sycon\\Lot');
$r->addAPIClass('noob\\sycon\\Measure');
$r->addAPIClass('noob\\sycon\\Operator');
$r->addAPIClass('noob\\sycon\\Payment');
$r->addAPIClass('noob\\sycon\\PaymentType');
Esempio n. 25
0
[![Forms](../resources/Form.gif)](users.html)
We have made it easy to try different styles
Also this example serves as an example for our Blade template integration

See bootstrap3.blade.php and foundation5.blade.php

Content:

*[bootstrap3.blade.php]: _016_forms/views/base/bootstrap3.blade.php
*[foundation5.blade.php]: _016_forms/views/base/foundation5.blade.php
*/
$loader = (include '../../../vendor/autoload.php');
$loader->setUseIncludePath(true);
use Luracast\Restler\Data\Validator;
use Luracast\Restler\Restler;
use Luracast\Restler\Defaults;
use Luracast\Restler\Format\HtmlFormat;
use Luracast\Restler\UI\Forms;
use Luracast\Restler\UI\FormStyles;
HtmlFormat::$viewPath = __DIR__ . '/views';
HtmlFormat::$template = 'blade';
Validator::$holdException = true;
$themes = array('amelia', 'cerulean', 'cosmo', 'cyborg', 'darkly', 'flatly', 'journal', 'lumen', 'readable', 'simplex', 'slate', 'spacelab', 'superhero', 'united', 'yeti');
$theme = isset($_GET['theme']) ? $_GET['theme'] : $themes[array_rand($themes, 1)];
$style = $theme == 'foundation5' ? 'foundation5' : 'bootstrap3';
HtmlFormat::$data += compact('theme', 'themes', 'style');
Forms::$style = FormStyles::${$style};
$r = new Restler();
$r->setSupportedFormats('HtmlFormat');
$r->addAPIClass('Users');
$r->handle();
Esempio n. 26
0
###Authorization###
The client apps role in authentication is two-fold. First it must direct the user to the server to start 
the process. And second, when the authorization has completed the client application's *callback* function will be executed
and it will be responsible for saving the authorization information. 

###Authentication###
Once the proper authorization has been attained by the client app, it's sole responsibility is to pass along it's 
authorization status in each RESTful API request. This is achieved by the client application adding a *query parameter* of 
'code' set to the access token that the OAuth Server provided to the application in the authorization step. 

> **Note:-**
> there is an optional parameter on the server that allows the Access Token to be passed as a header variable instead of a
> query parameter.

## In Conclusion ##
The "client application" plays an important role in the OAuth interaction and while your Restler server's primarily role will
likely be to play the *server* role in this process it is useful to know that both client and server are available as part of
the [OAuth 2.0 Server ](http://bshaffer.github.io/oauth2-server-php-docs/) module and both are easily made available to Restler. 

For more information on how to start using this functionality with Restler be sure to look at the [OAuth Server example](../_015_oauth2_server/index.php).
*/
require_once '../../../vendor/restler.php';
use Luracast\Restler\Restler;
use OAuth2\Client;
//This client takes to the server in the next folder, you can change it by un commenting
//Client::$serverUrl = 'http://brentertainment.com/oauth2/lockdin';
$r = new Restler();
$r->addAPIClass('OAuth2\\Client', '');
$r->setOverridingFormats('HtmlFormat', 'UploadFormat', 'JsonFormat');
$r->handle();
Esempio n. 27
0
 Requires: PHP >= 5.3
 Description: Shows the bare minimum code needed to get your RESTful api server
 up and running
Example 1: GET math/add returns 2
 Example 2: GET math/add?n1=6&n2=4 returns 10
 Example 3: GET math/multiply/4/3 returns {"result":12}
 Example 4: GET math/multiply/4/NaN returns
{
  "error": {
    "code": 400,
    "message": "Bad Request: invalid value specified for n2"
  }
}
Example 5: GET math/sum/1/2/3/4/5 returns 15

Content:

> **Note:-**
>
> 1. Take note of the php doc comments, they make sure the data is sent in the
>    right type and validated automatically before calling the api method.
> 2. Sum method accepts variable number of parameters with the help of
>    wildcard manual route. Read the [Routes](../_006_routing/readme.html)
>    example for better understanding
*/
require_once '../../../vendor/restler.php';
//smart auto loader helps loading a namespaced class with just the name part
use Luracast\Restler\Restler;
$r = new Restler();
$r->addAPIClass('Math');
$r->handle();
Esempio n. 28
0
<?php

require_once __DIR__ . '/../../../fw/includes.php';
require_once __DIR__ . '/../ExcelImport.php';
require_once __DIR__ . '/../../../api/vendor/restler.php';
use Luracast\Restler\Restler;
use Luracast\Restler\Format\UploadFormat;
$r = new Restler();
UploadFormat::$allowedMimeTypes = Config::get('allowedMimeTypes', 'excelImport');
$r->setSupportedFormats('JsonFormat', 'UploadFormat');
// some strange error in Restler when UploadFormat is mentioned as first parameter
$r->addAPIClass('ExcelImportApi', '');
$r->handle();
Esempio n. 29
0
<?php

/*
 * Testing all the attributes for @param annotation
 */
use Luracast\Restler\Restler;
use Luracast\Restler\Defaults;
require_once "../../../vendor/restler.php";
Defaults::$crossOriginResourceSharing = true;
$r = new Restler();
$r->addAPIClass('MinMax');
$r->addAPIClass('MinMaxFix');
$r->addAPIClass('Type');
$r->addAPIClass('Resources');
$r->handle();
Esempio n. 30
0
For example
    @url POST custom/path/{var1}/{var2}
### Wildcard Routes
Wildcard routes allows our api methods to receive variable number of parameters
they are manual routes that end with a star as the last path segment
For example
    @url GET custom/path/*
Take a look at the api class used here and compare it with the routes below to
understand.
Example 1: GET api/somanyways/1?p2=something returns "you have called Api::soManyWays()"
Example 2: GET api/somanyways/1/2 returns "you have called Api::soManyWays()"
Example 3: GET api/somanyways/1/2/3 returns "you have called Api::soManyWays()"
Example 4: GET api/what/ever/you/want returns
{
  "error": {
    "code": 400,
    "message": "Bad Request: anything is missing."
  }
}
Example 5: GET api/what/ever/you/want?anything=something returns
"you have called Api::whatEver()"
Example 6: GET api/all/1/2/3/4/5/6/7 returns
"you have called Api::allIsMine(1, 2, 3, 4, 5, 6, 7)"
Example 7: GET api/all returns
"you have called Api::allIsMine()"
*/
require_once '../../../vendor/restler.php';
use Luracast\Restler\Restler;
$r = new Restler();
$r->addAPIClass('Api');
$r->handle();