我刚刚使用composer将我的Codeigniter 4站点从4.1更新到4.2,现在在Apache错误日志中得到以下服务器错误:
PHP Fatal error: Uncaught Error: Call to a member function run() on int in /var/www/vhosts/site/public/index.php
我认为一个文件已经改变或CI 4.2需要一个缺失的PHP库,但我已经看了。env,/public/index.php和/app/config/app . PHP文件,他们没有改变。
任何帮助将非常感激!
Codeigniter v4.2.0的变化
index.php
和spark
文件在v4.2.0中有重大变化。要升级,必须合并新版本。
cd <root-dir-of-CI-project>
cp vendor/codeigniter4/framework/public/index.php public/index.php
和类似的标准CI4spark
(你没有修改它):
cd <root-dir-of-CI-project>
cp vendor/codeigniter4/framework/spark .
其他将index.php
和spark
的新版本与当前版本合并。
https://codeigniter4.github.io/userguide/installation/upgrade_420.html index-php-and-spark
您应该像这样修改index.php:
https://github.com/codeigniter4/CodeIgniter4/blob/develop/public/index.php
composer update
cp vendor/codeigniter4/framework/public/index.php public/index.php
cp vendor/codeigniter4/framework/spark
https://codeigniter4.github.io/CodeIgniter4/installation/upgrade_420.html
我从CI版本:4.1升级到4.2
一开始我使用命令:
作曲家更新
更新了我的CI框架和文件,但没有更新Spark和Index文件。
但是下面的命令修复了Spark和Index。我还在下面附上了CI文档链接:
composer update—prefer-source
https://codeigniter4.github.io/userguide/installation/installing_composer.html adding-codeigniter4-upgrading