将CakePHP 2应用程序升级为CakePHP 3应用程序,出现“无法声明App,因为名称已在使用”的错误。

3

我想将我的cakephp 2应用程序升级到cakephp 3,但遇到了问题。

我使用的是PHP 7.1和Ubuntu 16以及nginx / 1.10.0(Ubuntu)。

我得到了以下错误信息...

Fatal error: Cannot declare class lib\Cake\Core\App because the name is already in use in /usr/share/nginx/html/web/lib/Cake/Core/App.php on line 70

我正在关注这个页面:https://github.com/cakephp/upgrade

首先,我使用以下命令:

bin/cake upgrade locations [path]
bin/cake upgrade namespaces [path]
bin/cake upgrade app_uses [path]

bin/cake upgrade rename_classes [path]
bin/cake upgrade rename_collections [path]
bin/cake upgrade method_names [path]
bin/cake upgrade method_signatures [path]
bin/cake upgrade fixtures [path]
bin/cake upgrade tests [path]
bin/cake upgrade i18n [path]
bin/cake upgrade skeleton [path]
bin/cake upgrade prefixed_templates [path]

更多细节:

我的php版本是(输出php -v的结果):

PHP 7.1.0-5+deb.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.1.0-5+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans

我的Ubuntu版本(lsb_release -a 的输出)为:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.1 LTS
Release:    16.04
Codename:   xenial

现在面临相同的问题...你成功解决了吗? - Misha Akopov
1个回答

0

看起来你可能在include_path上安装了CakePHP,或以某种方式安装了升级插件,而不是在升级插件内部执行composer install。除非你已经将升级工具克隆到/usr/share/nginx/html/web/中。


升级插件位于 /usr/share/nginx/html/upgrade 中,我已经在 /bin 安装了 composer.phar,并使用它来安装升级工具。从 /usr/share/nginx/html/upgrade 内部运行所有 bin/cake upgrade [填写空白] ../web 命令。 - user904542
我有一个旧的CakePHP 2版本应用程序的备份。 - user904542
我使用了get_include_path来查找我的php包含路径,并在/usr/share/path中找到它,然后在那里执行ls命令,发现了这个:7.0 7.1 Archive Cake Console data docs OS PEAR pearcmd.php PEAR.php peclcmd.php PHP Structures System.php XML从该文件夹运行sudo find -name Cake给了我这个结果:./Cake ./data/CakePHP/Cake - user904542
我从 /usr/share/php 中删除了这两个 Cake 目录(我已备份它们),然后重新启动了 php7.1-fpm 和 nginx,并刷新了我的服务器,但错误仍然存在。 - user904542

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接