我已经对cakephp 3升级做了cakephp 2,这导致了问题,所以我发现我必须用一组新的文件替换app / webroot,这些文件是cakephp 3骨架的一部分,但现在我是收到此错误:
Fatal error: Uncaught Error: Class 'Cake\Http\Server' not found in /usr/share/nginx/html/web/app/webroot/index.php:33 Stack trace: #0 /usr/share/nginx/html/web/index.php(47): require() #1 {main} thrown in /usr/share/nginx/html/web/app/webroot/index.php on line 33
经过一番研究后,我找到了这个页面:https://api.cakephp.org/3.3/
,它显示了应该可用的类,我发现如果我转到my_cake_project/web/lib/Cake
并运行ls
,我会得到:
basics.php bootstrap.php config配置控制器错误I18n日志网络src测试实用程序视图 bin Cache配置控制台核心事件LICENSE.txt模型路由测试TestSuite VERSION.txt
但我错过了应该在CakePHP 3中的几个库,包括Http文件夹,我相信这就是找不到Cake / Http / Server的原因。
我已经跟踪了触发错误的行:
// Bind your application to the server.
$server = new Server(new Application(dirname(__DIR__) . '/config'));
这是在app / webroot / index.php。
我尝试将其拆分为:
$a = new Application(dirname(__DIR__) . '/config');
$server = new Server($a);
仅供测试,我发现它也说无法找到Class Application
。
这是app / webroot / index.php的整个文件:
<?php
/**
* The Front Controller for handling every request
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since 0.2.9
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
// for built-in server
if (php_sapi_name() === 'cli-server') {
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
$url = parse_url(urldecode($_SERVER['REQUEST_URI']));
$file = __DIR__ . $url['path'];
if (strpos($url['path'], '..') === false && strpos($url['path'], '.') !== false && is_file($file)) {
return false;
}
}
require dirname(dirname(__DIR__)) . '/vendors/autoload.php';
use App\Application;
use Cake\Http\Server;
// Bind your application to the server.
$server = new Server(new Application(dirname(__DIR__) . '/config'));
// Run the request/response through the application
// and emit the response.
$server->emit($server->run());
所以我必须错过Application类的文件
根据我在lib/Cake
文件夹中与https://api.cakephp.org/3.3/
的比较,我遗漏了一堆cakephp lib文件夹。
我似乎不仅缺少Http
,还缺少:
`Auth`, `Collection`, `Database`, `Datasource`, `Filesystem`, `Form`, `Mailer`, `ORM`, `Shell`, `Utility`, and `Validation`
为什么我错过了这些?,我在哪里或如何找到并将所有缺失的库安装到我的cakephp应用程序中?
答案 0 :(得分:0)
您尚未将所有依赖项下载到供应商文件夹。
我在Windows上使用OpenServer控制台
php composer.phar update
对我有帮助(之前我已将作曲家本地安装到我的项目中)。
在我看来,这是因为您安装了没有管理员权限的框架实例。
答案 1 :(得分:0)