【问题标题】:Fat Free Framework 3.0 and multiple filesFat Free Framework 3.0 和多个文件
【发布时间】:2013-02-03 03:19:19
【问题描述】:

我用 F3 (fat free framework) 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');
});

登陆.htm

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

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

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

感谢您的帮助/建议。

【问题讨论】:

    标签: fat-free-framework


    【解决方案1】:

    您的包含标签没有被渲染,因为您没有使用模板类...尝试

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

    代替视图

    【讨论】:

    • 我做了更改,现在看到:Undefined offset: 0 /Users/...My Projects/test/web/lib/base.php:136 Base->{closure}(8,'未定义的偏移量:0','/Users/.../My Projects/test/web/lib/base.php',136,array('key'=>NULL,'add'=>false,'parts'= >array())) /Users/..../My Projects/test/web/lib/base.php:178 Base->ref(NULL,false) /Users/.../My Projects/test/web /classes/AuthManager.php:20 Base->exists(NULL) PHP 致命错误:/Users/.../My Projects/test/web/lib/ 中允许的内存大小为 1077936128 字节用尽(尝试分配 130968 字节) base.php 在第 438 行
    • 嗯,... 仅凭那一点点信息进行远程调试并不容易。 “未定义的偏移量:0”行可能告诉了答案。也许您尝试在模板中使用未定义的变量。这在 v3 中已经不可能了。如果模板中存在该变量,则添加 条件或在控制器中设置默认值。如果您需要更多帮助,请向我们展示更多您的代码/子模板等...您也可以加入 IRC @freenode #fatfree
    • Doh,简单的数组索引问题。改变了它,现在它工作得很好。感谢您的努力:-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-27
    • 2015-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多