PHP code example of avalanche-development / talus

1. Go to this page and download the library: Download avalanche-development/talus 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/ */

    

avalanche-development / talus example snippets


$talus = new AvalancheDevelopment\Talus\Talus([..swagger..]);

function ($request, $response) {
  $someParameter = $request->getAttribute('swagger')['params']['someParameter'];
}

$talus->addController('getThing', function ($request, $response) {
  // get that thing
});

$talus->addController('getComplexThing', function ($request, $response) use ($db) {
  return (new Controller($db))->getComplexThing($request, $response);
});

$talus->addMiddleware(function ($request, $response, $next) {
  // do something
  return $next($request, $response);
});

$talus->setErrorHandler(function ($request, $response, $exception) {
  // do something with that exception
  return $response;
});

$talus = new AvalancheDevelopment\Talus\Talus([..swagger..]);

$talus->addController(..callback..);
$talus->addMiddleware(..callback..);

$talus->run();