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;








1















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);

);










share|improve this question



















  • 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

















1















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);

);










share|improve this question



















  • 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













1












1








1


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);

);










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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












  • 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












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
);



);














draft saved

draft discarded
















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
















draft saved

draft discarded















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해