Fat Free Framework 3.0和多个文件

时间:2013-02-03 03:19:20

标签: fat-free-framework

我用F3(无脂肪框架)2.0完成了一个简单的项目,一切都很棒。现在我正在开始一个新项目,我发现它已经改变了很多。我已经创建了一个简单的基本测试,并且只是保持错误和奇怪。我不是F3的专家,是的,我已经阅读了文档,当然我可能错过了一些东西。希望有人可以帮助我。这是我失败的例子:

从我的配置文件开始

的config.cfg

cfgDbConnection="mysql:host=localhost;port=8889;dbname=test";
cfgDbUser="root"
cfgDbPassword="123456"
cfgCache=true

// ...等

起点

的index.php

$f3=require('lib/base.php');
$f3->set('UI','ui/');
$f3->set('AUTOLOAD', 'classes/'); // this folder contains class objects for the project

$f3->config('config.cfg');
$f3->set('CACHE', $f3->get('cfgCache'));
$f3->set('DEBUG',3); 

$db = new DB\SQL(
    $f3->get('cfgDbConnection'),
    $f3->get('cfgDbUser'),
    $f3->get('cfgDbPassword')
);
$f3->set('DB',$db);

require_once("menuRoutes.php");
$f3->run();

用于路由的5个php文件中的第一个

menuRoutes.php

<?php
$f3->route('GET /', function() use ($f3){
    AuthManager::authenticateSession($f3); // checks if user is logged in /classes/AutManager.php 
    echo View::instance()->render('landing.htm');
});

landing.htm

<include href="mainHeaderBar.htm"/> (this has css & js loads)
general html.......
<include href="mainFooterBar.htm"/> (other jquery scripts)

此时页面加载了一般的html,CSS和JS脚本没有加载,因为包含没有加载,它们被忽略.......?

PHP日志显示:

HTTP 405 (HEAD /)
/Users/home/Documents/My Projects/testApp/web/index.php:39 Base->run()
ob_clean(): failed to delete buffer. No buffer to delete
/Users/home/Documents/My Projects/testApp/web/lib/base.php:859 ob_clean()
/Users/home/Documents/My Projects/testApp/web/lib/base.php:1118 Base->error(405)
/Users/home/Documents/My Projects/testApp/web/index.php:39 Base->run()
PHP Fatal error:  Uncaught exception 'ErrorException' with message 'ob_clean(): failed to delete buffer. No buffer to delete' in /Users/home/Documents/My Projects/testApp/web/lib/base.php:1391

感谢您的帮助/建议。

1 个答案:

答案 0 :(得分:3)

您的包含标记未呈现,因为您没有使用模板类...尝试

echo Template::instance()->render('landing.htm');

而不是View