V
V
Vlad Volodko2019-07-10 10:13:46
PHP
Vlad Volodko, 2019-07-10 10:13:46

Is it possible to include a php file in vue?

Hello, I'm interested in such a question, is it possible and if so, how to connect a php file to vuejs?

<template src="template.php">
</template>

Something like this
I know that only html is supported, but now there is such a need

Answer the question

In order to leave comments, you need to log in

8 answer(s)
D
Dima Pautov, 2019-07-10
@bootd

If you are trying to put the execution of php code into the vue template in this way, then you are doing something wrong)))
This, in principle, cannot be and it will not work))

A
Anton Shamanov, 2019-07-10
@SilenceOfWinter

I know that only html is supported, but now there is such a need
oh how everything is running ... you don't know anything jon snow .. nothing ..

O
Oleg, 2019-07-10
@YAZART

If you try really hard, you can do everything, but why?

E
Evgeniy S, 2019-07-10
@evgensenin

You can connect not only html, but also other template engines - pug for example. and in general - you can write your own loader for the webpack plugin (webpack deals with SFC components)
another question - WHY was such a NEED FOR? if you know why, maybe the community will tell you the right way to solve it.

V
Vlad Volodko, 2019-07-10
@Ruless

Yes, you are right, I did not quite fully describe the task of the site.
The site is written in cms bitrix, and it became necessary to translate one of the pages of the site into a framework, I chose vue.
In bitrix, the files have the php extension and there is both a template and functionality, since I chose vue, I want to make everything beautiful. The bitrix component is inserted into the page that needs to be redone via $APPLICATION->IncludeComponent
and now I'm wondering if I can somehow connect this component.

N
Nikita, 2019-07-10
@Emeralldo

I am not familiar with Bitrix, but judging by the description, it is possible to do so.
The page is written in php including markup and logic. So in the view you transfer the markup, and logic, and everything else. on the original page, delete everything except php code inserts, and hang some #app on the root div, and create a Vue application with el: "#app"

M
magersoft, 2019-07-10
@magersoft

Not very familiar with Bitrix. But I think there are controllers there, you write all PHP execution in the controller on the server, and give it to the view as json when mounted, for example

V
Vasily, 2019-07-10
Polosuhin @Polosuhin7

Work with Vue in library mode, register your Vue components globally, and connect the bundle to the template. Then you can use both Vue components and php inside the container

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question