【发布时间】:2017-05-21 12:01:30
【问题描述】:
我已经将 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 应用程序中?
【问题讨论】:
-
updrage 工具只处理了一些升级方面的事情,很多事情还是要手动完成。当然,您也有可能没有正确升级,例如很多人没有意识到升级工具是一个独立的应用程序。不再有
lib文件夹,包括CakePHP 核心在内的依赖项现在通过composer 进行管理,可以在vendors文件夹中找到。 -
您最好在CakePHP forums 或IRC/Slack 寻求帮助,在那里您可以就这个话题进行更长时间的讨论。
标签: php cakephp php-7 cakephp-3.3 php-7.1