3

As Laravel shipped with Vue Js framework,

I need to set a global variable to be accessible by Laravel as Backend, Also VueJs as Frontend to access it.

Both may change the value of this Global Variable. and Vue can pass it via api requests to Laravel.

I know that i can set it in .env file, So Vue can access it by process.env.VarName and Laravel can access it using method env('VarName') But it this case I can't change it in the run-time.

1 Answer 1

3

You can do:

let window.something = {{ config('something') }}

On the top of your main template - but as far as preimplemented 'declare once, available everywhere' - there is no such functionality implemented (as far as I know)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.