Cakephp 3给我致命错误:未捕获的错误:找不到类'Cake \ Http \ Server' [英] Cakephp 3 giving me Fatal error: Uncaught Error: Class 'Cake\Http\Server' not found

查看:198
本文介绍了Cakephp 3给我致命错误:未捕获的错误:找不到类'Cake \ Http \ Server'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了一个cakephp 2到cakephp 3的升级,这引起了问题,所以我发现我必须用cakephp 3框架中的一组新文件替换app/webroot.出现此错误:

I have done a cakephp 2 to cakephp 3 upgrade, and that was causing problems, so I found I had to replace the app/webroot with a new set of files that were part of the cakephp 3 skeleton, but now I am getting this error:

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,则会得到:

After some research, I found this page: https://api.cakephp.org/3.3/, which shows the classes that should be availabe, and I found that if I go to my_cake_project/web/lib/Cake and run ls I get:

basics.php bootstrap.php配置配置控制器错误I18n日志网络src测试实用程序视图 bin缓存配置控制台核心事件LICENSE.txt模型路由测试TestSuite VERSION.txt

basics.php bootstrap.php config Configure Controller Error I18n Log Network src tests Utility View bin Cache Config Console Core Event LICENSE.txt Model Routing Test TestSuite VERSION.txt

但是我缺少了一些应该包含在CakePHP 3中的库,包括Http文件夹,我相信这就是为什么找不到Cake/Http/Server的原因.

But I am missing several libraries that are supposed to be in CakePHP 3, including the Http folder, and I believe that is why Cake/Http/Server is not found.

我已经找到了触发错误的行:

I have tracked down the line that is triggering the error to this:

// Bind your application to the server.
$server = new Server(new Application(dirname(__DIR__) . '/config'));

这是在app/webroot/index.php中.

This is in app/webroot/index.php.

我尝试将其拆分为:

$a = new Application(dirname(__DIR__) . '/config');
$server = new Server($a);

仅用于测试,我发现这也表示找不到Class Application.

just for testing, and I found that it is also saying that the Class Application can not be found.

这是我拥有的app/webroot/index.php的整个文件:

This is the whole file of app/webroot/index.php that I have:

<?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类的文件

So I must be missing the file for the Application class too

基于对lib/Cake文件夹和https://api.cakephp.org/3.3/文件夹的比较,我缺少了一堆cakephp lib文件夹.

And based on comparing what I have in lib/Cake folder with https://api.cakephp.org/3.3/ I a missing a bunch of cakephp lib folders.

我似乎不仅想念Http,而且想念:

I seem to be missing not just Http, but also:

`Auth`, `Collection`, `Database`, `Datasource`, `Filesystem`, `Form`, `Mailer`, `ORM`, `Shell`, `Utility`, and `Validation`

为什么我会缺少这些?以及在哪里或如何找到所有缺少的库并将其安装到我的cakephp应用程序中?

Why am I missing these?, and where or how can I find and install all the missing libraries into my cakephp appliation?

推荐答案

您尚未将所有依赖项下载到供应商文件夹. 我在Windows上使用了OpenServer控制台, php composer.phar update对我有帮助(我之前在本地为我的项目安装了composer). 我认为,发生这种情况是因为您安装了没有管理员权限的框架实例.

You haven't downloaded all dependencies to vendor folder. I used OpenServer console on Windows and php composer.phar update was helpful for me (I had installed composer locally to my project before). In my opinion, that happened because you had installed the framework instance without Administrator rights.

这篇关于Cakephp 3给我致命错误:未捕获的错误:找不到类'Cake \ Http \ Server'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆