Migrating to php 8.2 - how to solve deprecated dynamics properties |
Hi,
I am trying to upgrade to php 8.2, but running into the deprecated dynamic properties issues and I am not sure how to solve it. In my BaseController, I prepare some elements I need within the views, but that generates the deprecated error. Here how it looks like: PHP Code: abstract class BaseController extends Controller I tried adding as suggested here https://stitcher.io/blog/deprecated-dyna...-in-php-82 the built-in attribute, but without success. PHP Code: #[AllowDynamicProperties] {What is the best way to solve this? Thanks for your help
Try to add:
PHP Code: use AllowDynamicProperties; But the best way is to define the properties you use. Because dynamic properties are deprecated. (12-18-2022, 05:47 PM)kenjis Wrote: Try to add: Use AllowDynamicProperties still does not work (or maybe I did not place it where it should for it to work. But I now understand what you meant by "define properties". PHP Code: protected $viewData = []; Thanks
(12-19-2022, 02:08 AM)kcs Wrote:(12-18-2022, 05:47 PM)kenjis Wrote: Try to add: After that, I got $_SESSION errors, do I need to update system folder something like change session.name to session.id?
What is the $_SESSION errors?
Can you show the exact error messages? (12-19-2022, 02:08 AM)kcs Wrote:(12-18-2022, 05:47 PM)kenjis Wrote: Try to add: This worked for me as well. Adding PHP Code: protected $session = []; PHP Code: $this->session = \Config\Services::session(); Thanks so much to kcs for the question, and to kenjis for the solution. context: PHP 8.2.1 Development Server via homebrew + CI4.2.11 `php spark serve` (Using CodeIgniter since 1.x)
|
Welcome Guest, Not a member yet? Register Sign In |