Wicked Strawberry
Wicked Strawberry

Reputation: 35

Is it possible to use PHP within Vue Components and Methods?

Is it possible to use PHP within Vue Components and Methods? (I'm using Vue CLI)

Upvotes: 2

Views: 7231

Answers (2)

Armand Biestro
Armand Biestro

Reputation: 201

As Dagalti was saying, you cannot. Even if PHP doesn't work on front-end as it si an hyper-text processor, you can manage to use both of them in a really nice way. first you can inject datas in your vue components BEFORE rendering, wich in some case is really usefull. It also doesnt mean you cannot use php as an api for your vue componants, some hacks are needed if you work on a native application, but it works well.

Beware if you are using php with Twig that you may need some tricks to handle the markdown.

I just implemented Vue in my php application,and it works pretty well, SSR or just rendering. tag me if you want to learn more about it. Here are some sources you may want to check out:

Upvotes: 0

dagalti
dagalti

Reputation: 1956

Not possible. check this post in vue help forum https://forum.vuejs.org/t/how-to-write-php-code-in-vue-js/15909

PHP is a “hypertext preprocessor” - it just runs once on the server and delivers a HTML document to the client. So you can’t make calls to PHP from Vue.

Upvotes: 4

Related Questions