![]() |
Migrating to php 8.2 - how to solve deprecated dynamics properties - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Migrating to php 8.2 - how to solve deprecated dynamics properties (/showthread.php?tid=85893) |
Migrating to php 8.2 - how to solve deprecated dynamics properties - kcs - 12-18-2022 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-dynamic-properties-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 RE: Migrating to php 8.2 - how to solve deprecated dynamics properties - kenjis - 12-18-2022 Try to add: PHP Code: use AllowDynamicProperties; But the best way is to define the properties you use. Because dynamic properties are deprecated. RE: Migrating to php 8.2 - how to solve deprecated dynamics properties - kcs - 12-19-2022 (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 ![]() RE: Migrating to php 8.2 - how to solve deprecated dynamics properties - volkankaban - 01-07-2023 (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? RE: Migrating to php 8.2 - how to solve deprecated dynamics properties - kenjis - 01-07-2023 What is the $_SESSION errors? Can you show the exact error messages? RE: Migrating to php 8.2 - how to solve deprecated dynamics properties - jasonzig - 01-16-2023 (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` |