PHP code example of jasonmichels / lift-framework
1. Go to this page and download the library: Download jasonmichels/lift-framework 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/ */
jasonmichels / lift-framework example snippets
declare(strict_types=1);
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use Lift\Framework\Http\Response;
function getHomepage(Request $request): JsonResponse {
$response = Response\json();
$response->setData(['data' => ['stuff' => 'is awesome']]);
return $response;
}
function getUserHandler (Request $request, array $args): JsonResponse {
$response = Response\json();
$response->setData(['data' => ['userId' => $args['id'], 'username' => 'Jason Michels']]);
return $response;
}
$app = new App();
$routes = [
['httpMethod' => Request::METHOD_GET, 'route' => '/', 'handler' => 'getHomepage'],
['httpMethod' => Request::METHOD_GET, 'route' => '/user/{id:\d+}', 'handler' => 'getUserHandler']
];
$app->run($routes);