我试图在fatfree框架中使用命名空间,但不知何故它无法找到以下类是我的设置
routes.ini
[routes]
GET /=Src\Controllers\Index->index
Run Code Online (Sandbox Code Playgroud)
的index.php
namespace Src\Controllers;
class Index {
function index($f3) {
$f3->set('name','world');
echo View::instance()->render('template.htm');
}
}
Run Code Online (Sandbox Code Playgroud)
全球index.php
// Retrieve instance of the framework
$f3=require('lib/base.php');
// Initialize CMS
$f3->config('config/config.ini');
// Define routes
$f3->config('config/routes.ini');
// Execute application
$f3->run();
Run Code Online (Sandbox Code Playgroud)
更新:
错误:
未找到
HTTP 404(GET /)
•index.php:13 Base-> run()
更新2:
config.ini文件
[globals]
; Where the framework autoloader will look for app files
AUTOLOAD=src/controllers/
; Remove next line (if you ever plan to put this app in production)
DEBUG=3
; Where errors …Run Code Online (Sandbox Code Playgroud)