Skip to content

Latest commit

 

History

History
43 lines (35 loc) · 805 Bytes

api.md

File metadata and controls

43 lines (35 loc) · 805 Bytes

API

  1. Build an api controller
  • make controller
php laragram make:api ApiName
  • remove controller
php laragram remove:api ApiName
  1. Open the created file ( path: App/Controller/Api )
  2. Start writing

Controller

namespace Bot\App\Controller\Api;

use Bot\Core\http\RegisterApi;

class DateTime extends RegisterApi
{
    public function time($country){
        // Request to api endpoint for get time
        return $time; // receive from api
    }
}

Usage

$api = new Api();

//$api->api('APIName@MethodName', ...$parameters);
$api->api('DateTime@time', 'iran');

// Helper 
//api('APIName@MethodName', ...$parameters);
api('DateTime@time', 'iran')