2

I have build an app with vue (not with vue cli). I ran It on my local host. What I am trying to do is to add php in this Project. But I cannot run php and vue on the same local host together. Is there a way to solve this problem ?

I know when the app is created with command line interface you can compile them with webpack. But how to combine back-end and front-end together when the app is created with vue?

Thanks a lot in advance

4
  • 1
    It is not possible to write php directly in a vue. Either you create an API using PHP or you use Laravel Commented Nov 13, 2018 at 9:54
  • you may need to create RESFUL API for php application as back end and vue js as front end application. or you can use laravel with vue but i think you just need to modify php application for that Commented Nov 13, 2018 at 10:28
  • Thanks for your answer. But I want to get the data of form which is on vue template. Must I do It with API? Commented Nov 13, 2018 at 10:43
  • Yes, you have to pass the form values from vue thru API to php Commented Nov 13, 2018 at 10:51

1 Answer 1

2

Vue is a javascript framework and I suppose you are familiar with javascript. In javascript, we use AJAX to interact with PHP. we used to send POST and GET request to the server via ajax and javascript and we get the response from the server.

In a similar way, you need to learn how to create Rest API for GET and POST via vueJS and PHP.

You Need to create Rest API for VueJS and PHP. There is no other solution. follow the links below as per your need.

  1. Here is the Github Link for the Same

  2. You can also use Laravel framework with Vue

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

2 Comments

Thank you guys. I did It
well done, please accept the answer by click check icon.

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.