- Build an api controller
- make controller
php laragram make:api ApiName
- remove controller
php laragram remove:api ApiName
- Open the created file ( path: App/Controller/Api )
- Start writing
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
}
}
$api = new Api();
//$api->api('APIName@MethodName', ...$parameters);
$api->api('DateTime@time', 'iran');
// Helper
//api('APIName@MethodName', ...$parameters);
api('DateTime@time', 'iran')