CakePHP 2.4.1$this->;webroot提供/而不是/app/webroot


CakePHP 2.4.1 $this->webroot gives / and not /app/webroot

我继承了一个CakePHP 2.4.1项目,如果我们想更改框架,我不想使用所有的html、css和脚本助手,因为这会使应用程序更加依赖CakePHP,但当我尝试使用加载脚本、样式和图像时

<?php echo $this->webroot; ?>css/app.min.css

但这会产生的URL

http://example.com/app.min.css

$this->webroot只返回/,我还不太熟悉CakePHP。是否有配置设置或其他设置正在改变这一点?我的vhosts文件指向webroot。

"Webroot"是可供公众访问的目录。它包含所有的资产元素,等等,它应该看起来像:

-- webroot
| -- assets
    | -- css
    | -- js
    | -- img
| -- index.php
//etc

因此,当您运行$this->webroot时,您将获得公共目录的路径。这假设所有资产文件都将位于该目录中。

如果这已经被修改,只需打开应用程序的index.php并找到以下行:

define('WEBROOT_DIR', 'MY_WEBROOT_DIR');

并将MY_WEBROOT_DIR更改为公共目录的实际名称,因为它位于within your CakePHP Application