Vue & Laravel: Call a PHP from a Vue component?Laravel requires the Mcrypt PHP extensionPass array to Laravel view and use that array as VueJS propSpeeding Up A Vue.js Component Under LaravelGetting error “Failed to mount component: template or render function not defined.” while using js file as Vue componentHow do you use laravel csrftoken in vue componentVue Component with Stripe JS v3Pass Props component to root InstanceUsing multiple pages (components) dynamically in Vue jspassing a callback function via props to child component is undefined in child vueWhen Passing Data Via Props From Laravel, Vue Component Not Rendering, Dumping Data
Knights and Knaves: What does C say?
rust-proof solution for attaching 2x4 to 4x4?
What does it mean by "my days-of-the-week underwear only go to Thursday" in this context?
Beyond Futuristic Technology for an Alien Warship?
When did Unix stop storing passwords in clear text?
What can Thomas Cook customers who have not yet departed do now it has stopped operating?
Why is STARTTLS used when it can be downgraded very easily?
Implementation of a Thread Pool in C++
To what degree did the Supreme Court limit Boris Johnson's ability to prorogue?
Delete n lines skip 1 line script
Why do Russians sometimes spell "жирный" (fatty) as "жырный"?
Can I pay some of the cost of an activated ability lots of times to get more out of the effect?
Why, even after his imprisonment, do people keep calling Hannibal Lecter "Doctor"?
A word that refers to saying something in an attempt to anger or embarrass someone into doing something that they don’t want to do?
My first Hangman game in Python
Why is a road bike faster than a city bike with the same effort? How much faster it can be?
Garage door sticks on a bolt
Worlds with different mathematics and logic
Avoiding dust scattering when you drill
Is there an in-universe explanation of how Frodo's arrival in Valinor was recorded in the Red Book?
What is the logical distinction between “the same” and “equal to?”
Why are the wings of some modern gliders tadpole shaped?
Is determiner 'a' needed in "one would call such a value a constant"?
My machine, client installed VPN,
Vue & Laravel: Call a PHP from a Vue component?
Laravel requires the Mcrypt PHP extensionPass array to Laravel view and use that array as VueJS propSpeeding Up A Vue.js Component Under LaravelGetting error “Failed to mount component: template or render function not defined.” while using js file as Vue componentHow do you use laravel csrftoken in vue componentVue Component with Stripe JS v3Pass Props component to root InstanceUsing multiple pages (components) dynamically in Vue jspassing a callback function via props to child component is undefined in child vueWhen Passing Data Via Props From Laravel, Vue Component Not Rendering, Dumping Data
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a blade template (php file) and I'm fine with passing in some PHP data as props that I encoded to json but how about if I need to specifically call a PHP function?
blade php file
<Component1
:customer-data= !! json_encode($customer->customerData)
>
</Component1>
Inside of my component, I am triggering a javascript function that starts the payment processor and the callback needs to trigger the PHP function which is checkoutWithCard(), which the blade file obviously can trigger but the component has no knowledge of it.
inside Component1.vue
initializeStripePayment: function()
var stripe = StripeCheckout.configure(
key: ######,
allowRememberMe: false,
token: function(token)
checkoutWithCard(token.id);
);
laravel vue.js laravel-blade
add a comment
|
I have a blade template (php file) and I'm fine with passing in some PHP data as props that I encoded to json but how about if I need to specifically call a PHP function?
blade php file
<Component1
:customer-data= !! json_encode($customer->customerData)
>
</Component1>
Inside of my component, I am triggering a javascript function that starts the payment processor and the callback needs to trigger the PHP function which is checkoutWithCard(), which the blade file obviously can trigger but the component has no knowledge of it.
inside Component1.vue
initializeStripePayment: function()
var stripe = StripeCheckout.configure(
key: ######,
allowRememberMe: false,
token: function(token)
checkoutWithCard(token.id);
);
laravel vue.js laravel-blade
5
You cannot call PHP functions in Javascript. You are probably going to need to make an XHR request (axios, $.ajax) in order to do this
– Derek Pollard
Mar 28 at 20:12
no problem! You should be able to find the resources you need with that in mind
– Derek Pollard
Mar 28 at 21:34
add a comment
|
I have a blade template (php file) and I'm fine with passing in some PHP data as props that I encoded to json but how about if I need to specifically call a PHP function?
blade php file
<Component1
:customer-data= !! json_encode($customer->customerData)
>
</Component1>
Inside of my component, I am triggering a javascript function that starts the payment processor and the callback needs to trigger the PHP function which is checkoutWithCard(), which the blade file obviously can trigger but the component has no knowledge of it.
inside Component1.vue
initializeStripePayment: function()
var stripe = StripeCheckout.configure(
key: ######,
allowRememberMe: false,
token: function(token)
checkoutWithCard(token.id);
);
laravel vue.js laravel-blade
I have a blade template (php file) and I'm fine with passing in some PHP data as props that I encoded to json but how about if I need to specifically call a PHP function?
blade php file
<Component1
:customer-data= !! json_encode($customer->customerData)
>
</Component1>
Inside of my component, I am triggering a javascript function that starts the payment processor and the callback needs to trigger the PHP function which is checkoutWithCard(), which the blade file obviously can trigger but the component has no knowledge of it.
inside Component1.vue
initializeStripePayment: function()
var stripe = StripeCheckout.configure(
key: ######,
allowRememberMe: false,
token: function(token)
checkoutWithCard(token.id);
);
laravel vue.js laravel-blade
laravel vue.js laravel-blade
asked Mar 28 at 19:55
RohimLRohimL
274 bronze badges
274 bronze badges
5
You cannot call PHP functions in Javascript. You are probably going to need to make an XHR request (axios, $.ajax) in order to do this
– Derek Pollard
Mar 28 at 20:12
no problem! You should be able to find the resources you need with that in mind
– Derek Pollard
Mar 28 at 21:34
add a comment
|
5
You cannot call PHP functions in Javascript. You are probably going to need to make an XHR request (axios, $.ajax) in order to do this
– Derek Pollard
Mar 28 at 20:12
no problem! You should be able to find the resources you need with that in mind
– Derek Pollard
Mar 28 at 21:34
5
5
You cannot call PHP functions in Javascript. You are probably going to need to make an XHR request (axios, $.ajax) in order to do this
– Derek Pollard
Mar 28 at 20:12
You cannot call PHP functions in Javascript. You are probably going to need to make an XHR request (axios, $.ajax) in order to do this
– Derek Pollard
Mar 28 at 20:12
no problem! You should be able to find the resources you need with that in mind
– Derek Pollard
Mar 28 at 21:34
no problem! You should be able to find the resources you need with that in mind
– Derek Pollard
Mar 28 at 21:34
add a comment
|
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405890%2fvue-laravel-call-a-php-from-a-vue-component%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405890%2fvue-laravel-call-a-php-from-a-vue-component%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
You cannot call PHP functions in Javascript. You are probably going to need to make an XHR request (axios, $.ajax) in order to do this
– Derek Pollard
Mar 28 at 20:12
no problem! You should be able to find the resources you need with that in mind
– Derek Pollard
Mar 28 at 21:34