plugins does not hande $GLOBALS correctly #54
-
|
see the code example below. If i run this on the vite dev server with this plugin, it prints null. $tbd = 'date has yet to be set';
function formatDate(string $datum): string
{
var_dump($GLOBALS['tbd']);
...
}Is this a bug? Or is there another way to use PHP globals with Vite? Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Hi @mathiasdg, interesting observation! In theory that should work as usual, but who knows if the configuration of PHPs build in dev-server is a little different from production or not... A couple of questions:
What I can say for sure, we have been explicitly setting the globals like: $GLOBALS['tbd'] = 'date has yet to be set';That does work for sure. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @donnikitos , thanks for the quick reply.
I did not think about setting the global explicitly, but that indeed works without a problem, so I will take that approach. Thank you |
Beta Was this translation helpful? Give feedback.
Hi @mathiasdg,
interesting observation! In theory that should work as usual, but who knows if the configuration of PHPs build in dev-server is a little different from production or not...
A couple of questions:
global $tbd;inside the function?What I can say for sure, we have been explicitly setting the globals like:
That does work for sure.