Questions tagged [slim-3]

Slim 3 is the successor to Slim 2, a micro framework for PHP.

Resources

Related tags


For the Ruby template engine use instead.

421 questions
41
votes
4 answers

Slim 3 - how to get all get/ put/ post variables?

How I can get all get/ put/ post variables like in Slim 2 for Slim 3? Slim 2, $allGetVars = $app->request->get(); $allPutVars = $app->request->put(); $allPostVars = $app->request->post(); How can I do that in Slim 3? And, for example,…
Run
  • 54,938
  • 169
  • 450
  • 748
18
votes
2 answers

How to access the $container within middleware class in Slim v3?

I've been reading that in Slim v2, $app was bound to the middleware class. I'm finding this not to be the case in v3? Below is my middleware class, but I'm just getting undefined:
Martyn
  • 6,031
  • 12
  • 55
  • 121
17
votes
1 answer

How do I manually initiate the 404 handler in Slim 3?

We already know how to add a custom 404 notFoundHandler in Slim 3: $container['notFoundHandler'] = function ($c) { return function ($request, $response) use ($c) { return $c->view->render($response, 'pages/404.html.twig') …
alexw
  • 8,468
  • 6
  • 54
  • 86
14
votes
3 answers

Slim 3: how to access settings?

Before the Slim 3 is released, codes below work fine: settings.php, return [ 'settings' => [ 'displayErrorDetails' => true, 'modules' => [ 'core' => 'config/core/modules.php', 'local' =>…
Run
  • 54,938
  • 169
  • 450
  • 748
11
votes
6 answers

Slim 3 get current route in middleware

I want to get the name of the current I route in a middleware class. Previously (in Slim 2.*) you could fetch the current route like so: $route = $this->app->router->getCurrentRoute(); But this function has been removed in the 3.0 version of Slim.…
Wessel van der Linden
  • 2,592
  • 2
  • 21
  • 42
10
votes
1 answer

Controller unit test in slim3

At the outset, I would like to say - I'm new in unit testing in PHP (phpunit). In my new project (slim3 framework) I would like to test my controllers for example LoginController. My idea is (in unit test method) Create instance of…
robertw
  • 724
  • 7
  • 20
9
votes
4 answers

Slim 3 getParsedBody() always null and empty

I'm am using the Slim Framework Version 3 and have some problems. $app-> post('/', function($request, $response){ $parsedBody = $request->getParsedBody()['email']; var_dump($parsedBody); }); result is always: null Can you help me ?
animatorist
  • 113
  • 1
  • 2
  • 6
9
votes
4 answers

Slim 3 Middleware Redirect

I want to check if a user is logged in. Therefor I have an Class witch returns true or false. Now I want a middleware which checks if the user is logged in. $app->get('/login',…
Stefan Roock
  • 153
  • 1
  • 5
9
votes
3 answers

Slim 3 Framework how to download file

I'm trying to download a file using the Slim 3 PHP Framework. Slim 2 was fairly straight forward, as I'm sure Slim 3 is too, but I just don't get it. Any help would be appreciated. Based on the documentation here :…
Jim_M
  • 273
  • 1
  • 2
  • 10
8
votes
1 answer

In PhpStorm warning method 'withJson' not found (Slim Framework)

In PhpStorm I get the warning message "warning method 'withJson' not found" in \Psr\Http\Message\ResponseInterface" at te line: return $response->withJson($toReturn, 200); The code: use \Psr\Http\Message\ServerRequestInterface as Request; use…
Wow
  • 177
  • 1
  • 8
8
votes
4 answers

Slim 3 multiple routes to one function?

I've been looking all over online and can't find anything that tells you how to assign multiple routes to one callback. For example I want to move: $app->get('/sign-in', function($request, $response) { return $this->view->render($response,…
Joe Scotto
  • 10,936
  • 14
  • 66
  • 136
7
votes
1 answer

Dependency Injection Slim Framework 3

I'm using Slim Framework 3 to create an API. The app structure is: MVCP (Model, View, Controller, Providers). Is it possible to have Slim Dependency Inject all my classes? I'm using composer to autoload all my dependencies. My directory structure…
Kearney Taaffe
  • 647
  • 8
  • 20
7
votes
1 answer

Slim3 optional parameter with controller method as callback

I have route: $app->get('/admin/login/{status}', 'App\Controller\Admin\AdminController:loginAction') How do I make {status} parameter optional?
Michal
  • 4,952
  • 8
  • 30
  • 63
6
votes
1 answer

Error 500 on a working docker container

I'm using a slimframwork 3 app on laradock (nginx, mariadb, phpfpm, php 5.6) so I made a stupid syntax error: $view->addExtension(new \Slim\Views\TwigExtension( $container->router, $container->request->getUri(), )); the comma after the getUri() was…
Getsuga
  • 559
  • 1
  • 7
  • 21
6
votes
2 answers

Generating tokens with slim-jwt-auth

I'm using slim-jwt-auth to create token based authentication for a JSON API. The docs are very helpful, but one thing I don't understand is how are the tokens generated? The docs say that the middleware is able to decode the token, but can't see any…
BugHunterUK
  • 8,346
  • 16
  • 65
  • 121
1
2 3
28 29