Few Questions on Slim Frameworks

Written few interview questions on slim framework Request community to review and add more questions. here is link
https://www.onlineinterviewquestions.com/slim-interview-questions/

Is Slim framework similar to Symfony’s Silex? How do they differ?
Since Silex is kindof dead, make it another micro-framework (like lumen)

How can you install Slim Framework v2?
Make it V3, because V2 is outdated

What is Dependency Injection?
Has nothing to do with Slim, the only thing is: Slim uses it

What is a hook in Slim Framework?
Outdated

What is Slim framework?

  • Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.

How is Slim framework different from other frameworks like Laravel, Symfony or Zend?

Is Slim framework similar to Symfony’s Silex? How do they differ?

  • Silex is micro-framework based on the Symfony Components.
  • Silex is not based on the PSR-7 (HTTP message interfaces) standard
  • Silex is in maintenance mode. Ends of life is set to June 2018.

How would you define a middleware in Slim?

Example:

use Slim\Http\Request;
use Slim\Http\Response;

$app->add(function (Request $request, Response $response, $next) {
    $response->getBody()->write('BEFORE');
    $response = $next($request, $response);
    $response->getBody()->write('AFTER');

    return $response;
});

How can you install Slim Framework v2?

  • Slim 2 is outdated. Use Slim 3.

How can you set and get a cookie in Slim Framework?

  • You can use the native PHP functions or a cookie/session libary of your choice.

How to define route groups in Slim Framework?

List some Environment Variables of Slim Framework?

  • There are no Slim specific environment variables.

What is Dependency Injection?

What is a hook in Slim Framework?

  • This is a old Slim 2 (event handler) concept. Better use Slim 3 and a middleware.