Google News
logo
Slim Framework - Interview Questions
What is an Application i Slim Framework?
The Application Slim\App is the entry point to your Slim application and is used to register the routes that link to your callbacks or controllers.
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;

require __DIR__ . '/../vendor/autoload.php';

// Instantiate app
$app = AppFactory::create();

// Add Error Handling Middleware
$app->addErrorMiddleware(true, false, false);

// Add route callbacks
$app->get('/', function (Request $request, Response $response, array $args) {
    $response->getBody()->write('Hello World');
    return $response;
});

// Run application
$app->run();
Advertisement