# Few Questions on Slim Frameworks

**URL:** <https://discourse.slimframework.com/t/few-questions-on-slim-frameworks/2508>\
**Category:** Questions\
**Created:** [July 1, 2018, 11:25pm UTC](https://discourse.slimframework.com/t/few-questions-on-slim-frameworks/2508 "2018-07-01T23:25:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![devquora](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/devquora/32/702_2.png) [@devquora](https://discourse.slimframework.com/u/devquora)\
**Post date:** [July 1, 2018, 11:25pm UTC](https://discourse.slimframework.com/t/few-questions-on-slim-frameworks/2508/1 "2018-07-01T23:25:35Z")

</div>

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/](https://www.onlineinterviewquestions.com/slim-interview-questions/)

---

<div class="post-metadata">

**Author:** ![marcelloh](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/marcelloh/32/404_2.png) [@marcelloh](https://discourse.slimframework.com/u/marcelloh)\
**Post date:** [July 2, 2018, 8:28am UTC](https://discourse.slimframework.com/t/few-questions-on-slim-frameworks/2508/2 "2018-07-02T08:28:57Z")

</div>

**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

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [July 2, 2018, 9:06am UTC](https://discourse.slimframework.com/t/few-questions-on-slim-frameworks/2508/3 "2018-07-02T09:06:01Z")

</div>

#### 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?

- Slim is a [micro framework](https://en.wikipedia.org/wiki/Microframework) (Routing). Laravel/Symfony/Zend is a [full-stack framework](https://blog.appdynamics.com/engineering/php-microframework-vs-full-stack-framework/).

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

- Silex is micro-framework based on the [Symfony Components](https://symfony.com/components).
- Silex is not based on the PSR-7 (HTTP message interfaces) standard
- Silex is in maintenance mode. [Ends of life](https://symfony.com/blog/the-end-of-silex) is set to June 2018.

#### How would you define a middleware in Slim?

Example:

```php
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?

- [Route Groups](https://www.slimframework.com/docs/v3/objects/router.html#route-groups)

#### List some Environment Variables of Slim Framework?

- There are no Slim specific environment variables.

#### What is Dependency Injection?

- [Wikipedia](https://en.wikipedia.org/wiki/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.
