Slim 4 is an open source PHP micro framework that helps writing web applications and APIs.
Questions tagged [slim-4]
93 questions
1
vote
1 answer
Slim 4 & Webpack Error manifest file not exists
I am setting up Slim 4 PHP application and I am building JS & CSS with Webpack 4. I followed code from Github and Slim tutorial but I always get the error:
Type: Twig\Error\LoaderError
Code: 0
Message: Webpack manifest file not exists.
My…

dubaksk
- 91
- 2
- 10
1
vote
0 answers
slim/twig-view Won't Work With Additional Route Middleware
I've been using slim/twig-view, documented here: https://notes.enovision.net/slim/composer-package-documentation/slim_twig-view. The recommended way to handle a route, render a view is:
$app->get('/hello/{name}', function ($request, $response,…

Robert Moskal
- 21,737
- 8
- 62
- 86
1
vote
1 answer
php slim app not redirecting to index.php if specified route does not exist
I just finished the installation guide of setting up a php slim app. Everything is working fine except when the user specifies an url that doesn't exist in the app, he is not getting redirected to the index.php.
I think it has something to do with…

Ruben
- 515
- 1
- 5
- 19
1
vote
2 answers
Slim Framework throws 405 Not Found Error on every request
I am trying to build Slim Framework Version 4 api, for my angular application.
On every request i make, i get
Type: Slim\Exception\HttpMethodNotAllowedException
Code: 405
Message: Method not allowed. Must be one of: POST
File:…

Alaksandar Jesus Gene
- 6,523
- 12
- 52
- 83
1
vote
1 answer
Modify routes and url when using Varnish
I have a project where Varnish is used in front of a Slim 4 project. Due to some project specialities, the original url should be hidden and the incoming request is rewritten to some other headers.
Example
Original call to demo.xyz is coming to…

codedge
- 4,754
- 2
- 22
- 38
1
vote
1 answer
How to set up multiple PDO database connections in slim 4 and access them in a repository?
I tried to set up SLIM 4 with 2 PDO database connections.
I can't access the db nor db2 from a repository.
I guess I'm doing something wrong
I followed the slim 4 skeleton.
I created a db.php file in app for adding the db's definition in the…

Patrice Flao
- 491
- 5
- 18
1
vote
2 answers
Respect\Validation custom Rule with PDO?
I am learning Slim Framework v4 and decided to use Respect\Validation to validate inputted data and have hit a snag where I do not know how to inject the PDO into my custom rule I created.
The idea is to validate some inputs against the database if…

Kristjan O.
- 814
- 1
- 9
- 33
1
vote
1 answer
How to get registered routes in Slim Framework 4
In Slim Framework 3 we can get all registered routes using this code
$routes = $this->container->get("router")->getRoutes();
Unfortunately this doesn't seem to work in slim 4. Is there any other way to get registered routes in slim 4 ?
thanks

sad301
- 386
- 1
- 3
- 8
1
vote
2 answers
How do I implement CSRF protection with Slim 4 and slim/csrf?
Slim 4 is already here and I am trying to move to Slim 4. Everything is great, but CSRF returns an error when i try to implement it. I tried the simplest setup, but I get this error:
Message: Argument 2 passed to Slim\Csrf\Guard::__invoke() must be…

AlexBet
- 572
- 5
- 13
1
vote
2 answers
I keep getting this error on Slim 4 after installing new version 4.12
I keep getting this error Slim Application Error after installing the new Slim 4 framework.
I tried switching back to old version of slim but I keep getting the same thing.

Kyle Mutta
- 379
- 1
- 5
- 16
0
votes
1 answer
Slim 4 + Angular 10 : donwload pdf api is returning empty data in angular blob response
I am trying to integration download pdf angular api with slim 4 api. I can see the response returning from the slim on browser network, but when I try to parse the response in angular it is returning empty. I have added the required headers on both…

prisel
- 337
- 2
- 14
0
votes
0 answers
Slim4 and PHP-DI doesn't inject using annotation
I'm migrating a project from an older version of Slim and PHP-DI to the last one and PHP 8.1.17.
These are the composer dependency for slim and php-di:
"slim/slim" : "~4.11",
"php-di/php-di" : "^7.0.2",
PHP-DI annotation doesn't work like the…

Tobia
- 9,165
- 28
- 114
- 219
0
votes
0 answers
REST API url in api subdomain and regualr app in www domain with Slim4
I'm trying to get the api calls for our app from the subdomain, it's not working as desired.
$app->group('/api', function (RouteCollectorProxy $group) {
$group->get('/home', [\App\Controllers\HomeController::class, 'apihome']);
});
I've set our…

Kim K.
- 121
- 2
- 13
0
votes
0 answers
Slim4 register_shutdown_function method not sending response
After trying various versions of my methods, I'm not getting any closer to fixing.
In the following code I just check for a time out and call the next method accordingly.
It does show all the echo'ed lines all the way to the end, except for sending…

Kim K.
- 121
- 2
- 13
0
votes
1 answer
Setting global session var in Slim4 and Twig
I'm been having issues with this for weeks on numerous plugins/extensions, so I am afraid I'm stuck.
It would be very helpful if I can use session data in all Twig templates, not just the ones parsed by Controllers via the Render method, like this…

Kim K.
- 121
- 2
- 13