CakePHP 3 debug_kit 带有子目录
CakePHP 3 debug_kit with subdirectory
本地开发,现在一切都转移到服务器上。它工作正常,但 debugkit 显示不正确。
我无法访问 js,css 等。所以我只看到一个空盒子,里面没有加载蛋糕图片。数据写入数据库(我使用的是标准连接,只是插入了 panels 和 requests 表。
所以我猜这就是造成这一切的原因。或者我的应用程序安装在 sub/sub 目录中。
bootstrap.php
if (Configure::read('debug')) {
Plugin::load('DebugKit', ['bootstrap' => true]);
}
app.php
'debug' => filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN),
'debug_kit' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'XXX-IP',
//'port' => 'nonstandard_port_number',
'username' => 'XXXDB', // Your DB username here
'password' => 'XXXPW', // Your DB password here
'database' => 'scdb',
'encoding' => 'utf8',
'timezone' => 'UTC',
'cacheMetadata' => true,
'quoteIdentifiers' => false,
//'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
]
它试图处理的 link 是:
https://www.example.com/sub/sub2/debug_kit/webroot/css/reset.css
蛋糕在sub2文件夹
来自 webroot 的 htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sub/webroot
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url= [QSA,L]
</IfModule>
来自 sub2 的 htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
CakePHP 3.x 不会自动提供插件资产,除非 asset filter is enabled. The simplest solution is to symlink the plugin files to the webroot:
bin/cake plugin assets symlink
一般推荐用于任何插件资产。
应该注意的是,您应该从不在生产安装上使用调试工具包,因为这是一个相当明显的安全问题。
好的,我现在明白了,愚蠢的错误 - 但我仍然想知道为什么它可以在我的其他系统上运行:/
RewriteBase /sub/sub2
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/ [L]
之前我在 webroot/
前面有一个斜线
感谢@AD7six 的支持。我很感激。
本地开发,现在一切都转移到服务器上。它工作正常,但 debugkit 显示不正确。
我无法访问 js,css 等。所以我只看到一个空盒子,里面没有加载蛋糕图片。数据写入数据库(我使用的是标准连接,只是插入了 panels 和 requests 表。
所以我猜这就是造成这一切的原因。或者我的应用程序安装在 sub/sub 目录中。
bootstrap.php
if (Configure::read('debug')) {
Plugin::load('DebugKit', ['bootstrap' => true]);
}
app.php 'debug' => filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN),
'debug_kit' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'XXX-IP',
//'port' => 'nonstandard_port_number',
'username' => 'XXXDB', // Your DB username here
'password' => 'XXXPW', // Your DB password here
'database' => 'scdb',
'encoding' => 'utf8',
'timezone' => 'UTC',
'cacheMetadata' => true,
'quoteIdentifiers' => false,
//'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
]
它试图处理的 link 是: https://www.example.com/sub/sub2/debug_kit/webroot/css/reset.css
蛋糕在sub2文件夹
来自 webroot 的 htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sub/webroot
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url= [QSA,L]
</IfModule>
来自 sub2 的 htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
CakePHP 3.x 不会自动提供插件资产,除非 asset filter is enabled. The simplest solution is to symlink the plugin files to the webroot:
bin/cake plugin assets symlink
一般推荐用于任何插件资产。
应该注意的是,您应该从不在生产安装上使用调试工具包,因为这是一个相当明显的安全问题。
好的,我现在明白了,愚蠢的错误 - 但我仍然想知道为什么它可以在我的其他系统上运行:/
RewriteBase /sub/sub2
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/ [L]
之前我在 webroot/
感谢@AD7six 的支持。我很感激。