【问题标题】:Upgrade cakephp 2 app -> cakephp 3 app, `Cannot declare App because the name is already in use`升级 cakephp 2 应用程序 -> cakephp 3 应用程序,`无法声明应用程序,因为名称已在使用中`
【发布时间】:2017-05-20 08:44:09
【问题描述】:

我在尝试将我的 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

【问题讨论】:

  • 现在面临同样的问题...您设法解决问题了吗?

标签: php cakephp cakephp-2.0 cakephp-3.0 php-7


【解决方案1】:

看起来您可能在 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 [fill in the blank] ../web 命令
  • 我确实有我的应用程序的旧 cakephp 2 版本的备份
  • 好吧,我使用 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
  • 我从 /usr/share/php 中删除了这两个 Cake 目录(我备份了它们)并重新启动了 php7.1-fpm 和 nginx,并刷新了我的服务器,我仍然得到相同的结果错误。
猜你喜欢
  • 1970-01-01
  • 2014-11-04
  • 2016-06-27
  • 2012-11-13
  • 1970-01-01
  • 1970-01-01
  • 2012-05-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多