我已经将 cakephp 2 升级到 cakephp 3,这导致了问题,所以我发现我必须用一组新的文件替换 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 Configure Controller Error I18n Log Network src tests Utility View bin Cache Config Console Core Event 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 应用程序中?