# DefaultServiceProvider Error

**URL:** https://discourse.slimframework.com/t/defaultserviceprovider-error/2993
**Category:** Questions
**Created:** [February 27, 2019, 10:19pm UTC](https://discourse.slimframework.com/t/defaultserviceprovider-error/2993 "2019-02-27T22:19:47Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![doktor1360](https://avatars.discourse-cdn.com/v4/letter/d/8e7dd6/32.png) [@doktor1360](https://discourse.slimframework.com/u/doktor1360)
#### Post date: [February 27, 2019, 10:19pm UTC](https://discourse.slimframework.com/t/defaultserviceprovider-error/2993/1 "2019-02-27T22:19:47Z")

</div>

Hey y’all…

First time out the door implementing Slim, and everything was OK until I ran the app I’m working on from the server (_nginx_). I quickly cobbled together the 1st app walkthru code existing of only the ‘hello’ route, it works as advertised on the local php server. However, when netbeans uploaded to a test server (_vanilla nginx server_) and I ran the same application here’s what I get regardless using the php server or nginx:

```
[Wed Feb 27 16:59:17 2019] 192.168.1.67:50444 [500]: /home/check - Uncaught Error: Call to undefined method Slim\Router::setCacheFile() in /srv/www/workspace/infraweb/vendor/slim/slim/Slim/DefaultServicesProvider.php:96

```

Cant figure this one out… composer?!? Workstation and server are updated, not showing any errors when using composer from the cli on either box. It’s quite probable I’ve done something cement headed but I’m not quite sure. The one thing after reading I’m kinda wondering is about the _DefaultServicesProvider_ reference, as I didn’t do anything like install the framework; I simply required Slim in composer and went to work. I used an array structure with the defaults defined in the documents for loading the slim app. If I deserve a shin-kicking here, please be gentle, however any and all constructive criticism is greatly welcomed and encouraged.

Thanx in advance!

---

<div class="post-metadata">

### Author: ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)
#### Post date: [February 28, 2019, 8:02am UTC](https://discourse.slimframework.com/t/defaultserviceprovider-error/2993/2 "2019-02-28T08:02:39Z")

</div>

This looks like a autoloading / namespace bug [here](https://github.com/slimphp/Slim/blob/3.x/Slim/DefaultServicesProvider.php#L96)…

```php
$router = (new Router)->setCacheFile($routerCacheFile);

```

because there is maybe a missing `use Slim\Router;` statement on top of the file. I will ask the Slim core developers to take a look at it.

---

<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: [February 28, 2019, 8:24am UTC](https://discourse.slimframework.com/t/defaultserviceprovider-error/2993/3 "2019-02-28T08:24:01Z")

</div>

We don’t need `use Slim\Router` because `DefaultServicesProvider` is in the `Slim` namespace.

---

<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: [February 28, 2019, 8:25am UTC](https://discourse.slimframework.com/t/defaultserviceprovider-error/2993/4 "2019-02-28T08:25:28Z")

</div>

The `Router` has a [`setCacheFile` method](https://github.com/slimphp/Slim/blob/3.x/Slim/Router.php#L131), so I’m unclear what’s going on here.

Which version of Slim are you running?

---

<div class="post-metadata">

### Author: ![doktor1360](https://avatars.discourse-cdn.com/v4/letter/d/8e7dd6/32.png) [@doktor1360](https://discourse.slimframework.com/u/doktor1360)
#### Post date: [February 28, 2019, 6:14pm UTC](https://discourse.slimframework.com/t/defaultserviceprovider-error/2993/5 "2019-02-28T18:14:26Z")

</div>

Gentlemen… thx so much for the quick reply.

@odan - yeah odan, that’s the line, the $routerCacheFile is ‘false’ based on debugging.

@akrabat hey Rob, I’m using ‘^3.0’ in composer.

I think there’s an issue with developers & the server, something ‘_magically_’ got mangled regarding permissions and it may have caused a composer issue, I’m looking into that - opens up a bigger can of worms. My thoughts are if the vanilla debug smoke test works on a local php server running in the project, the router is is working as advertised, correct? In which case, it’s the issue would most likely be some combination of composer (_a mixed bag config-wise?_), permissions, uploads to the server, netbeans and/or something other fart-knockery in the work flow.

Let me look at this a bit closer regarding the above, and I’ll revisit with anything that turns up (_including any ‘egg on my face’_) accordingly to get this mitigated and closed out. Stay tuned…

Thanx so much in advance - apologies for waste of anyone’s personal bandwidth…

---

<div class="post-metadata">

### Author: ![doktor1360](https://avatars.discourse-cdn.com/v4/letter/d/8e7dd6/32.png) [@doktor1360](https://discourse.slimframework.com/u/doktor1360)
#### Post date: [March 1, 2019, 5:47am UTC](https://discourse.slimframework.com/t/defaultserviceprovider-error/2993/6 "2019-03-01T05:47:11Z")

</div>

After some troubleshooting, turned out to be a Composer problem after-all. After tackling that and mitigating the issue, I’ve got the framework & server/workstation workflow ironed out with all parties. The default application is serving locally and on the development server. Documented things for others that are involved too so I don’t have to repeat this again.

@odan & @akrabat - thanx SO MUCH for quickly jumping in on this, greatly appreciated. It’s also pretty kewl knowing that if I ever run into something that’s a directly related slim issue, I can certainly get things addressed quickly here and get things mitigated in a real timely fashion!

---

<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: [March 1, 2019, 10:38am UTC](https://discourse.slimframework.com/t/defaultserviceprovider-error/2993/7 "2019-03-01T10:38:25Z")

</div>

I’m glad you found it!

---

<div class="post-metadata">

### Author: ![psharma](https://avatars.discourse-cdn.com/v4/letter/p/b9e5f3/32.png) [@psharma](https://discourse.slimframework.com/u/psharma)
#### Post date: [March 8, 2019, 12:11am UTC](https://discourse.slimframework.com/t/defaultserviceprovider-error/2993/8 "2019-03-08T00:11:33Z")

</div>

Hi  
Can you tell me how you resolved the issue?

I think I am running into a simmilar issue.  
I am getting the error:  
Call to undefined method Slim\Router::setCacheFile()

My post method is defined as:  
$app-\>post("/signup", function() {

// attempt to send to local host db

});

---

<div class="post-metadata">

### Author: ![doktor1360](https://avatars.discourse-cdn.com/v4/letter/d/8e7dd6/32.png) [@doktor1360](https://discourse.slimframework.com/u/doktor1360)
#### Post date: [March 8, 2019, 2:41am UTC](https://discourse.slimframework.com/t/defaultserviceprovider-error/2993/9 "2019-03-08T02:41:46Z")

</div>

I’d have to take a stab at stating your Slim\Router reference object is questionable. Without seeing how you access (_and/or create_) the Router reference, pretty much anything I add is all speculative. One thing’s for certain, the Router object reference itself is questionable and it’s the 1st thing I’d personally look into, because the method DOES exist in the router code…

However, your actual mileage may vary…
