Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
166 views
in Technique[技术] by (71.8m points)

php yaf配置问题

#nginx.conf
        location /wx
        {
            root /wx/public/index.php;
            if (!-e $request_filename) {
              rewrite ^/wx/(.*)$ /wx/public/index.php?$1 last;
            }
        }
//public/index.php
<?php
define('BASE_URL', 'http://localhost/wx/');
define("APP_PATH",  realpath(dirname(__FILE__) . '/../'));

$app  = new Yaf_Application(APP_PATH . "/conf/application.ini");
$app->bootstrap()->run();
#conf/application.ini
[product]
application.directory=APP_PATH "/application/" 
application.dispatcher.catchException = TRUE
application.dispatcher.throwException = TRUE
application.modules=index,admin
application.view.ext = 'php'

为什么这样配置,访问http://localhost/wx会提示

Page was not found
Failed opening controller script /home/wwwroot/default/wx/application/controllers/Wx.php: No such file or directory
#0 /home/wwwroot/default/wx/public/index.php(7): Yaf_Application->run()
#1 {main}

public/index.php打印$_REQUEST,是个空数组
图片描述

目录结构:bootstrap.php在zapplication下,入口文件index.php在public下
补充一下,把域名绑定到/home/wwwroot/default/wx,用域名是可以访问的(rewrite规则要对应修改,不是上面那个),rewrite规则改成上面那个,再使用http://ip/wx访问(wx是yaf项目目录),就不行了。会把/wx/当成控制器


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

终于有问Yaf的了,真开森,楼主上下您的结构吧,是Yaf 没找到你的引导。


设定了adminindex 两模型,你将项目目录设定到../application/ 所以您的bootstarp,php也应该在这目录下,当bootstrap被调用的时刻, Yaf_Application就会默认的在APPLICATION_PATH下, 寻找Bootstrap.php, 而这个文件中, 必须定义一个Bootstrap类, 而这个类也必须继承自Yaf_Bootstrap_Abstract

楼主不妨在控制器下建立wx.php尝试一下,结构有些乱哈


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...