超薄3路由无法正常工作

时间:2016-05-12 14:13:27

标签: php api routes slim

我正在尝试在我的班级用户中定义一个使用方法的路线。

在index.php中我有这个:

// Create a new configuration
var config = new BusConfiguration();

// Make sure to add the ServiceControl plugin assembly
config.AssembliesToScan(
  AllAssemblies.Matching("NServiceBus").And("ServiceControl.Plugin").ToList()
);

在dependencies.php中我有:

$app->post('/user', '\Users:getUsers');

在我的班上,我有:

$container['\Users'] = function ($container) {

 return new Users($container->get('ci'));

};

我得到的错误是未找到类'用户'

知道为什么吗?

1 个答案:

答案 0 :(得分:1)

您的用户类未在项目的任何位置定义。 它可能来自您在dependencies.php中的用法

看起来你没有使用自动加载...所以请确保你要包含一个声明,以便在执行的某个地方包含该类。

您应该为您的班级使用PSR-4命名空间。