1. Go to this page and download the library: Download dbeurive/slim-controller 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/ */
dbeurive / slim-controller example snippets
namespace dbeurive\Slim\Test\controller0;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use dbeurive\Slim\controller\Controller;
/**
* Class ProfileController
* @package dbeurive\Slim\Test\controller0
*/
class ProfileController extends Controller
{
/**
* Create or update a profile.
* @param Request $request
* @param Response $response
* @return Response
*/
public function actionPostSet(Request $request, Response $response) {
$response->getBody()->write("Profile has been set! (" . $this->app->getContainer()[FLAG] . ')');
return $response;
}
/**
* Get a profile.
* @param Request $request
* @param Response $response
* @return Response
* @uri-params {id}
*/
public function actionGetGet(Request $request, Response $response) {
$response->getBody()->write("This is the requested profile data (" . $this->app->getContainer()[FLAG] . ')');
return $response;
}
}
use dbeurive\Slim\controller\Manager as ControllerManager;
$app = new \Slim\App([]);
ControllerManager::start($app, '/app/data/index.json');
$app->run();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.