CodeIgniter Forums
Upgrading from 4.1.8 to 4.2.0 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: Upgrading from 4.1.8 to 4.2.0 (/showthread.php?tid=82081)



Upgrading from 4.1.8 to 4.2.0 - kabeza - 06-09-2022

Hi
I went through the process of upgrading codeigniter from 4.1.8 to 4.2.0
I've the framework installed through composer

I executed the following commands

Code:
rm public/index.php
rm ./spark

Then the commands stated in user Guide
https://codeigniter.com/user_guide/installation/upgrading.html

Code:
> composer update
> cp vendor/codeigniter4/framework/public/index.php public/index.php
> cp vendor/codeigniter4/framework/spark .

Now I cannot run the App because I'm getting this in the Apache logs

Code:
[Thu Jun 09 11:10:14.915165 2022] [php7:error] [pid 1931744] [client 10.2.132.217:49362] PHP Fatal error:  Uncaught Error: Call to a member function run() on int in /var/www/myweb/index.php:40\nStack trace:\n#0 {main}\n  thrown in /var/www/myweb/index.php on line 40

Should I also copy (and overwrite) the vendor/codeigniter4/framework/public/index.php to /var/www/myweb/index.php ?

I don't remember why I have that index.php in root, but I guess it was for sef urls or to remove index.php from url

Thanks a lot


RE: Upgrading from 4.1.8 to 4.2.0 - iRedds - 06-09-2022

public/index.php is the entry point.
It is specially separated from the application for security reasons.
You need to change the virtual host configuration so document_root points to the public folder.


RE: Upgrading from 4.1.8 to 4.2.0 - samiam - 06-09-2022

(06-09-2022, 08:02 AM)iRedds Wrote: public/index.php is the entry point.
It is specially separated from the application for security reasons.
You need to change the virtual host configuration so document_root points to the public folder.

But composer update does not change that.  I have the same problem.  Working fine before the update.  Followed the update instructions, now my install is broken.  I had to re-initialize a new project and then copy all my custom files over again, which is a huge PiTA.  I wouldn't want to have to do that every time I upgrade CodeIgniter.  Didn't have to change anything with my document root which was already set up correctly.


RE: Upgrading from 4.1.8 to 4.2.0 - kenjis - 06-09-2022

(06-09-2022, 07:49 AM)kabeza Wrote: Now I cannot run the App because I'm getting this in the Apache logs

Code:
[Thu Jun 09 11:10:14.915165 2022] [php7:error] [pid 1931744] [client 10.2.132.217:49362] PHP Fatal error:  Uncaught Error: Call to a member function run() on int in /var/www/myweb/index.php:40\nStack trace:\n#0 {main}\n  thrown in /var/www/myweb/index.php on line 40

Should I also copy (and overwrite) the vendor/codeigniter4/framework/public/index.php to /var/www/myweb/index.php ?

Yes, because you moved /public/index.php to /index.php.
You are not using /public/index.php, so updating it does not make sense.

And it is recommended to use /public/index.php, not /index.php for security reasons.
If you can change the document root, change it to the public/ folder.