CAKEPHP - 将默认路径更改为 webroot

CAKEPHP - Change default path to webroot(CAKEPHP - 将默认路径更改为 webroot)
本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)