Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for PHP 8.3 #6278

Open
yasinuddowla opened this issue Apr 22, 2024 · 15 comments
Open

Support for PHP 8.3 #6278

yasinuddowla opened this issue Apr 22, 2024 · 15 comments

Comments

@yasinuddowla
Copy link

I wanted to use PHP 8.3 with CI 3.1.13

I've installed PHP 8.3 and it gives the following error.

A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_URI::$config is deprecated
Filename: core/URI.php
Line Number: 102
Backtrace:
  File: /Users/yasinuddowla/sites/dana/portal/public/admin.php
  Line: 299
  Function: require_once
@jafjaf
Copy link

jafjaf commented Apr 23, 2024

Codeigniter 3.1.13 don't support PHP >8.2 (yet), you can however update on your own using these changes

If you instead would like an updated repo with PHP 8.2 support see;

@otengkwame
Copy link

otengkwame commented Apr 23, 2024

I am extending a copy of CodeIgniter 3 that works with PHP 8.3 from here: https://github.com/sylynder/webby, https://github.com/sylynder/engine. I am also borrowing some concepts from CodeIgniter 4

@putuardiworks
Copy link

@jafjaf, I would like to ask: with the current CodeIgniter v3.1.13, what is the latest stable PHP version that works out-of-the-box?

@mariolucasdev
Copy link

@jafjaf, I would like to ask: with the current CodeIgniter v3.1.13, what is the latest stable PHP version that works out-of-the-box?

currently i have 2 projects using the Codeigniter version 3.1.13 running with php 8.2.

@jafjaf
Copy link

jafjaf commented May 26, 2024

@jafjaf, I would like to ask: with the current CodeIgniter v3.1.13, what is the latest stable PHP version that works out-of-the-box?

A fresh install of Codeigniter 3 supports PHP version up to and including 8.1.
If you're going to start a new project it's better to use Codeigniter 4, however if you're already using Codeigniter 3 and need PHP support above 8.1 you can implement the changes mentioned above.

I'm also running multiple projects using PHP 8.3 and Codeigniter 3 (with PHP >8.2) changes implemented.
More specifically these changes

@putuardiworks
Copy link

I didn't expect to get a response this fast. Wow, the community is still great 🥳

@mariolucasdev Do you run CodeIgniter v3.1.13 with PHP 8.2 without making any changes to the system?

@jafjaf So, it is safe to use PHP 8.1? And if I want to upgrade to PHP 8.2 or higher, then I need to make the changes you mentioned? I am still working on a CodeIgniter 3 project, so I need to know which is the latest PHP version that is safe to upgrade to.

@jafjaf
Copy link

jafjaf commented May 27, 2024

I didn't expect to get a response this fast. Wow, the community is still great 🥳

@mariolucasdev Do you run CodeIgniter v3.1.13 with PHP 8.2 without making any changes to the system?

@jafjaf So, it is safe to use PHP 8.1? And if I want to upgrade to PHP 8.2 or higher, then I need to make the changes you mentioned? I am still working on a CodeIgniter 3 project, so I need to know which is the latest PHP version that is safe to upgrade to.

It depends on how you define "safe."

  • The repository is >10 years old.
  • CodeIgniter 3 no longer has active official support.
  • There is only one official maintainer.
  • It has been superseded by the more up-to-date CodeIgniter 4 framework.

However, the community remains quite active, and there are ongoing efforts to keep CodeIgniter 3 viable with updates and patches.

Supporting PHP versions for CodeIgniter 3

  • PHP 8.1: Generally considered safe to use with CodeIgniter 3, with some minor adjustments.
  • PHP 8.2 and higher: Require changes to ensure compatibility.

@poodle123
Copy link

Pocketarc Fork already works with PHP 8.3 without any issues. You just have to adapt your own code where needed:

https://github.com/pocketarc/codeigniter

@jafjaf
Copy link

jafjaf commented May 29, 2024

Pocketarc Fork already works with PHP 8.3 without any issues. You just have to adapt your own code where needed:

https://github.com/pocketarc/codeigniter

Quoting jamieburchell below from #6173

The releases from this fork appear to be based on the develop branch and from scanning the commits, include functionality changes. The develop branch is quite a bit different to the last released version.

IMO it would be better to cherry-pick and apply specific fixes to the latest actual release/master if you want to keep as close as possible to the last official 3.1.13 release.

@vvp3
Copy link

vvp3 commented Jun 19, 2024

Ty for your effor tfirst of all !

Second, I am not a senior so I would not want to do some mistakes, but do it step by step with some help if possilble.
Please tell me if following closely the changes here : master...ib3ltd:CodeIgniter:master
will help me get to 8.2 at least if not even 8.3

Also, how should I best test the changes ?

  1. install phpstan and run it to point me the errors and fix them ?
  2. or apply the changes above directly and after that run phpstan for more checks ? I never used phpstan in CI to check errors hence me asking dumb q.

Furthermore, in the official 8.1 and 3.13 I have no issues with the code.
Is there a way to have in every changed file something like #if php ver = 8.1 .. have this code and if php ver = 8.2 (8.3) have this one ?
I do not want to move far away from the official 8.1 + 3.13 so that if there are problems I can revert easy to 8.1

Thank you !

@jafjaf
Copy link

jafjaf commented Jun 20, 2024

Ty for your effor tfirst of all !

Second, I am not a senior so I would not want to do some mistakes, but do it step by step with some help if possilble. Please tell me if following closely the changes here : master...ib3ltd:CodeIgniter:master will help me get to 8.2 at least if not even 8.3

Also, how should I best test the changes ?

1. install phpstan and run it to point me the errors and fix them ?

2. or apply the changes above directly and after that run phpstan for more checks ? I never used phpstan in CI to check errors hence me asking dumb q.

Furthermore, in the official 8.1 and 3.13 I have no issues with the code. Is there a way to have in every changed file something like #if php ver = 8.1 .. have this code and if php ver = 8.2 (8.3) have this one ? I do not want to move far away from the official 8.1 + 3.13 so that if there are problems I can revert easy to 8.1

Thank you !

I'm running with those exact changes in multiple projects without issues.

You don't have to go out of your way to test the changes, every commit to the branch is tested and backwards compatible, see here.

Don't overcomplicate the changes, you're only creating more work for yourself if in case you introduce bugs to the system files.

If you don't want to move away from the official release, have faith on the maintainer(s) to introduce support for PHP +8.2 and wait.

@vvp3
Copy link

vvp3 commented Jun 20, 2024

@jafjaf appreciate your answer but I am not very savy in moving in and out of commits.

Besides system and application folder and their files, is there any other folder I should check for modifications ?
If I apply those modifications to the files prior to moving to 8.2 (will it crash CI or parts of it ?) ?
"every commit to the branch is tested and backwards compatible, " >> or this answers exactly my question :)

Do I also need to modify many of my models, views, controllers manually too ?

ps. Besides here I didn't find anythink regarding mantainer(s) to intrpduce support fpr 8.2+ so the wiat would be in vain.

@jafjaf
Copy link

jafjaf commented Jun 20, 2024

@jafjaf appreciate your answer but I am not very savy in moving in and out of commits.

Besides system and application folder and their files, is there any other folder I should check for modifications ? If I apply those modifications to the files prior to moving to 8.2 (will it crash CI or parts of it ?) ? "every commit to the branch is tested and backwards compatible, " >> or this answers exactly my question :)

Do I also need to modify many of my models, views, controllers manually too ?

ps. Besides here I didn't find anythink regarding mantainer(s) to intrpduce support fpr 8.2+ so the wiat would be in vain.

You can view all files changed here.
If you follow the changes carefully it should be fine.

All changes are compatible with PHP 5 and above.

"If I apply those modifications to the files prior to moving to 8.2 (will it crash CI or parts of it ?) ?" Are you suggesting to implement all the changes straight to production? Don't, Always test before with multiple versions to ensure compatibility.

"Do I also need to modify many of my models, views, controllers manually too ?" Depends on how your code looks, if you're using deprecated functions you have to update them as well.

If the changes scare you that much you can always migrate to Codeigniter 4, which have support for PHP +8

@vvp3
Copy link

vvp3 commented Jun 21, 2024

Codeigniter 3.1.13 don't support PHP >8.2 (yet), you can however update on your own using these changes

If you instead would like an updated repo with PHP 8.2 support see;

* https://github.com/ib3ltd/CodeIgniter/tree/master

* https://github.com/pocketarc/codeigniter

The first link is what I needed.
Applying those changes to the system files made it work but some small errors in the login page - I am sure it is only becasue dynamic deprecated and I must input it in those classes as well.

Is this #[AllowDynamicProperties] causing any issue as I did not see it in developer branch (there are some modifications here I wouldn't put as they are over my head and I don't think I need them)

I am in 8.2 now. Will the changes from the master branch be enough for 8.3 ? Did you test it ?

Ty again for your patience and answers !

@jafjaf
Copy link

jafjaf commented Jun 21, 2024

@vvp3 i'm using 8.2 in production and 8.3 in testing environments without issues.
You can read more about AllowDynamicProperties here.

It's not in the main devlop branch because it haven't been merged yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants