CAKEPHP - 将默认路径更改为 webroot [英] CAKEPHP - Change default path to webroot

查看:39
本文介绍了CAKEPHP - 将默认路径更改为 webroot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 cakephp 的新手,我在设置本地开发服务器时遇到了一些问题.我的蛋糕安装位于 http://localhost/dropbox/my_site/.但是,当我尝试访问该 url 时,它告诉我未设置 Dropbox 控制器.我如何告诉 CakePHP 从 my_site 而不是 /localhost/ 开始?

I'm new to cakephp and I'm having some problems with setting up a local development server. I have my cake install located at http://localhost/dropbox/my_site/. However, when I try to visit that url, it tells me the dropbox controller isn't set up. How do I tell CakePHP to start in my_site rather than /localhost/?

我已经尝试将 connect(/localhost/dropbox/*) 添加到路由中,但它似乎仍然在错误的位置寻找模型.

I've tried adding connect(/localhost/dropbox/*) to the routes, but it seems like it still looks for models in the wrong location.

我尝试在 app/webroot 中编辑 index.php,但所有示例都显示了如何以 linux 格式而不是 windows 格式编写目录,所以我不确定如何构建ROOT"

I tried editing index.php in app/webroot but all the examples show how to write the directory in linux format rather than windows, so I'm not sure how to structure 'ROOT'

推荐答案

CakePHP 将在子目录中愉快地工作 - 我有几个 Cake 站点在 上运行http://localhost/{appname} 在我的开发机器上.

CakePHP will work happily in a subdirectory - I have several Cake sites running at http://localhost/{appname} on my dev machine.

Cake 在根 index.php 文件中定义了它的 ROOT 目录.如果你往里面看,你会看到以下几行:

Cake defines its ROOT directory in the root index.php file. If you look inside you'll see the following lines:

define('ROOT', dirname(__FILE__));
define('WEBROOT_DIR', 'webroot');
define('WWW_ROOT', ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS);

因为它从 dirname(__FILE__) 获取 ROOT,所以它总是指向那个文件的位置.

Since it's taking ROOT from dirname(__FILE__), it will always point to that file's location.

我怀疑您的路由文件有问题.您是否创建了任何自定义路由规则来说明位于子目录中?如果你这样做了,你的蛋糕安装可能会尝试访问 http://localhost/dropbox/my_site/dropbox/a>... 这就是为什么您会收到该错误.

I suspect you have problems in your routing file. Did you create any custom routing rules to account for being located in a subdirectory? If you did, your cake install may be trying to access http://localhost/dropbox/my_site/dropbox/... and that's why you're getting that error.

这篇关于CAKEPHP - 将默认路径更改为 webroot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆