Organize routes into separate files not working properly in Slim

ε祈祈猫儿з 提交于 2019-12-02 00:00:17

Okay, your problem is that you basically create three instances of application: one in index.php, one in users.php, one in org.php.

Application instance is created by

$app = new \Slim\App;

And that application is launched by $app->run.

In index.php you have $app, which is overriten by $app in users.php, then overwritten by $app in org.php.

This is the reason why require '../src/routes/users.php'; seems to be ignored - it's declaring $app, adds routes and in the next file you overwrite $app and add routes.

To fix this, simply remove

$app = new \Slim\App;

from everywhere but index.php.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!