【发布时间】:2017-02-19 13:27:01
【问题描述】:
在我决定实施命名空间之前,我的项目运行良好。从那以后,我遇到了一些问题。我熟悉了this post,它有类似的问题,但没有运气。我也读过the documentation about namespaces,但也没有用。
我的文件结构如下:
-fatfree
-index.php
-app
-config.ini
-routes.ini
-controllers
-Controller.php
-DeviceController.php
-models
-*.php
-views
-*.html
-lib
base.php
...
我的routes.ini 文件如下所示:
[routes]
GET @devices: /devices = \Controllers\DeviceController->devices
我的DeviceController 类看起来像:
<?php
namespace Controllers;
class DeviceController extends \Controller
{
public function devices($f3)
{
...
}
...
}
我的index.php 文件如下所示:
<?php
$f3 = require("lib/base.php");
$f3->config("app/config.ini");
$f3->config("app/routes.ini");
new Session();
$f3->run();
当我导航到设备页面时,我收到以下错误:
找不到
HTTP 404 (GET /devices)
[/fatfree/lib/base.php:1462] Base->error(404) [/fatfree/index.php:13] Base->run()
【问题讨论】:
-
请提供您的
index.php文件的代码。 -
我刚刚编辑了我的帖子以包含
index.php的内容 -
从文档中,建议使用小写命名自动加载的 php 文件,并使用 camelCase 命名类名
标签: php namespaces fat-free-framework