DefaultServiceProvider Error

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] [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!

This looks like a autoloading / namespace bug here

$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.

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

The Router has a setCacheFile method, so I’m unclear what’s going on here.

Which version of Slim are you running?

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…

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!

1 Like

I’m glad you found it!

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


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…