gpt4 book ai didi

php - Cakephp 3 给我 fatal error : Uncaught Error: Class 'Cake\Http\Server' not found

转载 作者:行者123 更新时间:2023-12-05 07:45:36 25 4
gpt4 key购买 nike

我已经完成了 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 配置配置 Controller 错误 I18n 日志网络 src 测试实用程序 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 库文件夹。

我似乎不仅缺少 Http,还缺少:

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

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

最佳答案

您尚未将所有依赖项下载到 vendor 文件夹。我在 Windows 上使用了 OpenServer 控制台,并且php composer.phar update 对我很有帮助(我之前已经在我的项目本地安装了 composer)。在我看来,这是因为您在没有管理员权限的情况下安装了框架实例。

关于php - Cakephp 3 给我 fatal error : Uncaught Error: Class 'Cake\Http\Server' not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41510526/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com