Welcome Guest, Not a member yet? Register   Sign In
Why use `global $app` in Toolbar Class?
#1

Hi, I found the "global $app;" used in the prepare method of the "CodeIgniter\Debug\Toolbar" Class.


In the new version of CodeIgniter4 we can use "\Config\Services::codeigniter()" to get the shared CodeIgniter entity. So I'm not sure if using "global $app;" is needed.

Since I am doing some work for CodeIgniter4 to support high performance servers (RoadRunner & WorkerMan), so "global $app;" is a problem that bothers me.
Reply
#2

Probably just because the code was written before Services::codeigniter() was added.
Reply
#3

(This post was last modified: 08-31-2022, 12:51 AM by ping-yee.)

We changed  "global $app;" to "$app = \Config\Services::codeigniter();" and run unit test below of "tests/system/Debug/" folder, It looks like doesn't have any problem.
Does this change need to be modified at next version?
Reply
#4

This was fixed in develop, and will be fixed in v4.2.7.
See https://github.com/codeigniter4/CodeIgniter4/pull/6524
Reply




Theme © iAndrew 2016 - Forum software by © MyBB