Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shahidkarimi's avatar

Access global variable in routes

I create and register a global variable in the app.js as Vue.prototype.$golableVar = 'somevalue'

Now when I try to access this in route like this.$globalVar it doent work.

Any clue?

0 likes
2 replies
Nakov's avatar

if you show the code, it will be much easier for someone to help.

If you are trying to use that variable within web.php or api.php files it will never work, and the clue is pretty simple. One is JavaScript file, and the other one is PHP file.

JavaScript = Client side PHP = Server side

Please or to participate in this conversation.