# Internal server error 500 on DELETE method

**URL:** https://discourse.slimframework.com/t/internal-server-error-500-on-delete-method/940
**Category:** Questions
**Created:** [November 24, 2016, 6:05pm UTC](https://discourse.slimframework.com/t/internal-server-error-500-on-delete-method/940 "2016-11-24T18:05:57Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![elmartino](https://avatars.discourse-cdn.com/v4/letter/e/58f4c7/32.png) [@elmartino](https://discourse.slimframework.com/u/elmartino)
#### Post date: [November 24, 2016, 6:05pm UTC](https://discourse.slimframework.com/t/internal-server-error-500-on-delete-method/940/1 "2016-11-24T18:05:57Z")

</div>

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.

Regards,  
Martin

---

<div class="post-metadata">

### Author: ![llvdl](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/llvdl/32/78_2.png) [@llvdl](https://discourse.slimframework.com/u/llvdl)
#### Post date: [November 24, 2016, 8:19pm UTC](https://discourse.slimframework.com/t/internal-server-error-500-on-delete-method/940/2 "2016-11-24T20:19:26Z")

</div>

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

```php
<?php

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

$app = new \Slim\App();

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

$app->run();

```

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

---

<div class="post-metadata">

### Author: ![elmartino](https://avatars.discourse-cdn.com/v4/letter/e/58f4c7/32.png) [@elmartino](https://discourse.slimframework.com/u/elmartino)
#### Post date: [November 24, 2016, 8:35pm UTC](https://discourse.slimframework.com/t/internal-server-error-500-on-delete-method/940/3 "2016-11-24T20:35:23Z")

</div>

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

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.

---

<div class="post-metadata">

### Author: ![elmartino](https://avatars.discourse-cdn.com/v4/letter/e/58f4c7/32.png) [@elmartino](https://discourse.slimframework.com/u/elmartino)
#### Post date: [November 24, 2016, 8:43pm UTC](https://discourse.slimframework.com/t/internal-server-error-500-on-delete-method/940/4 "2016-11-24T20:43:40Z")

</div>

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]);

Working:  
$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…

---

<div class="post-metadata">

### Author: ![llvdl](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/llvdl/32/78_2.png) [@llvdl](https://discourse.slimframework.com/u/llvdl)
#### Post date: [November 24, 2016, 9:42pm UTC](https://discourse.slimframework.com/t/internal-server-error-500-on-delete-method/940/5 "2016-11-24T21:42:51Z")

</div>

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

---

<div class="post-metadata">

### Author: ![elmartino](https://avatars.discourse-cdn.com/v4/letter/e/58f4c7/32.png) [@elmartino](https://discourse.slimframework.com/u/elmartino)
#### Post date: [November 24, 2016, 9:53pm UTC](https://discourse.slimframework.com/t/internal-server-error-500-on-delete-method/940/6 "2016-11-24T21:53:51Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![akrabat](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/akrabat/32/9_2.png) [@akrabat](https://discourse.slimframework.com/u/akrabat)
#### Post date: [November 25, 2016, 10:35am UTC](https://discourse.slimframework.com/t/internal-server-error-500-on-delete-method/940/7 "2016-11-25T10:35:31Z")

</div>

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:

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

```

---

<div class="post-metadata">

### Author: ![elmartino](https://avatars.discourse-cdn.com/v4/letter/e/58f4c7/32.png) [@elmartino](https://discourse.slimframework.com/u/elmartino)
#### Post date: [November 25, 2016, 10:42am UTC](https://discourse.slimframework.com/t/internal-server-error-500-on-delete-method/940/8 "2016-11-25T10:42:31Z")

</div>

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

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();

---

<div class="post-metadata">

### Author: ![elmartino](https://avatars.discourse-cdn.com/v4/letter/e/58f4c7/32.png) [@elmartino](https://discourse.slimframework.com/u/elmartino)
#### Post date: [November 25, 2016, 10:58am UTC](https://discourse.slimframework.com/t/internal-server-error-500-on-delete-method/940/9 "2016-11-25T10:58:48Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![elmartino](https://avatars.discourse-cdn.com/v4/letter/e/58f4c7/32.png) [@elmartino](https://discourse.slimframework.com/u/elmartino)
#### Post date: [November 25, 2016, 11:07am UTC](https://discourse.slimframework.com/t/internal-server-error-500-on-delete-method/940/10 "2016-11-25T11:07:40Z")

</div>

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

---

<div class="post-metadata">

### Author: ![elmartino](https://avatars.discourse-cdn.com/v4/letter/e/58f4c7/32.png) [@elmartino](https://discourse.slimframework.com/u/elmartino)
#### Post date: [November 25, 2016, 3:42pm UTC](https://discourse.slimframework.com/t/internal-server-error-500-on-delete-method/940/11 "2016-11-25T15:42:04Z")

</div>

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.
