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.

414 questions
38
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,…
laukok
  • 47,545
  • 146
  • 388
  • 689
17
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
  • 4,941
  • 9
  • 40
  • 97
16
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
  • 7,044
  • 6
  • 46
  • 81
13
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' =>…
laukok
  • 47,545
  • 146
  • 388
  • 689
11
votes
5 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,214
  • 2
  • 17
  • 38
9
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
  • 694
  • 7
  • 18
9
votes
2 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
  • 7
8
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
  • 113
  • 1
  • 4
7
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
  • 119
  • 8
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
  • 580
  • 6
  • 16
6
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
  • 8,050
  • 7
  • 41
  • 100
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
  • 6,765
  • 7
  • 41
  • 94
6
votes
8 answers

Unreasonable Errors on PHP Slim 3 Middleware

I am trying to use the ValidationErrorsMiddleware.php class as a middleware, so I added the following code to my bootstrap/app.php: $app->add(new App\Middleware\ValidationErrorsMiddleware($container)); I got the following errors after the above…
DarkSpirit
  • 197
  • 1
  • 2
  • 6
5
votes
1 answer

Slim 3 - remove subdir from url with rewrite rule

I have a shared hosting on A2Hosting and I recently moved my main domain from public_html/ to public_html/subdir/ Here's the structure: /public_html /subdir(site files of main domain) /api index.php My current htaccess(public_html) is :…
Efbi
  • 412
  • 2
  • 10
  • 34
5
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
  • 388
  • 4
  • 16
1
2 3
27 28