Internal server error 500 on DELETE method

Hi all!

I’m using SLIM 3.5.0 for creating a rest api. I use Angular2 to talk to the API.
The app->get() routes do work fine! The app->delete() routes doesn’t work unfortunately. I always get an internal server error 500 if i use the delete route. Even if i remove all that’s inside it and just echo the id:

$app->delete('/news/{id}', function ($request, $response, $args) {		
echo $args['id'];				

above this route i have a get /news route that is working fine. Even if i replace delete with get, it’s just working fine.

I also have a SLIM v2 version on another directory, and if i call the delete route there, it is just working fine.

So does anybody see what i’m doing wrong? I’m sure it’s not Angular, beceause also with another REST client i get the 500 error. It’s not the server, because the v2 api is working with delete. So it must be something with the v3 slim i guess…

Thanks in advance.


I don’t see anything wrong, so I tried running the following application, but cannot reproduce your error:


require_once __DIR__ . '/../vendor/autoload.php';

$app = new \Slim\App();

$app->delete('/news/{id}', function ($request, $response, $args) {
    echo $args['id'];


Can you provide a minimal working example that produces the error?

Thanks for your reply! With your code it is working actually… It’s making it even stranger :slight_smile:

However, i do see this error: Parse error: syntax error, unexpected ‘[’ in \api\vendor\nikic\fast-route\src\functions.php on line 12

But it’s still working. I will try to add my custom stuff one by one to see if i can find the problem.

Ok… I’m one step further…

I found that it’s in this part:

Not working:
$settings = require DIR . ‘./src/settings.php’;
$app = new \Slim\App([“settings” => $config]);

$app = new \Slim\App();

However… I need the settings, because my db connection info is in there:

<?php $config['displayErrorDetails'] = true; $config['debug'] = true; $config['addContentLengthHeader'] = false; $config['db']['host'] = "host"; $config['db']['user'] = "user"; $config['db']['pass'] = "pass"; $config['db']['dbname'] = "dbname"; ?>

Any tips?

And to be clear: GET methods don’t give any problem! I’m lost…

The syntax error is strange. I can’t say what is causing it.

Just to check: do you have a return $config; statement at the end of src/settings.php?

No, i didn’t had that. I just added it, but nothing changed.

The delete and put methods are not working, post and get are working. If i remove the config they are all working.

Your settings.php file needs to return $config; at the end and should not have ?> at the end.

Update: Actually, that’s not your problem, so ignore it

The instantiation of App should look like this though to avoid confusion:

require __DIR__ . './src/settings.php';
$app = new \Slim\App(["settings" => $config]);

Thanks for your reply! I changed it like you said, but no luck :frowning:

require DIR . ‘./src/settings.php’;
$app = new \Slim\App([“settings” => $config]);

Still the same error 500. Response is empty.

This is not giving the error:

require DIR . ‘./src/settings.php’;
$app = new \Slim\App();

Ok, one step further…
I changed config.php:

return [
‘settings’ => [
‘displayErrorDetails’ => true,
‘addContentLengthHeader’ => false,

    'db' => [
        'host' => 'host',
        'user' => 'user',
        'pass' => 'pass',
        'dbname' => 'dbname',


and index.php:

$config = require ‘./src/config.php’;
$app = new \Slim\App($config);

This works, as long as i have set this: ini_set(‘display_errors’, 1);
If i comment this out, i get the error 500 message again…

I’m getting crazy!

Hmm, i get a http 200 now… but the route is not giving back any simple response like echo “test”;

Fixed!! The problem was on the webserver with multiple php versions conflicting. phpinfo gave 5.6.24, but 5.3.x was used for the Verbs other then get, post or head.

Thanks all!

In addition: the parse error was because php version < 5.4 don’t supports short array syntax. So for delete and put methods, the 5.3 version was used.