K
K
KropovEvg2020-12-27 16:35:41
Vue.js
KropovEvg, 2020-12-27 16:35:41

How to rewrite code in VUE CLI?

Hello dear programmers!
I understand that api is written in PHP and then we access this file through Java Script. Now I want to rewrite my code to VUE CLI and I've run into a problem that I can't access the PHP file.
Please tell me not the code, but the direction. Am I doing something wrong? Just a schematic - how do I implement a simple idea with an API, because for example, INSTAGRAM recommends using PHP for security?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2020-12-28
@DKWLB

The crux of the matter is now clear after reading the comments. You mixed salty with red.
Php has nothing to do with it. You can't just create a php file in your vue folder and expect miracles from it. No, you can create something, but it will not work.
The php file needs a separate php server.
Depending on the development environment. openserver?
Or did you just run npm run serve in your vue folder?
Install openserver or xampp. This is the easiest/fastest. It all depends on the scale and tasks. What should data.php return. database data? Or static data? Then you can simply create a .json file in the folder with vue and take data from it and php is not needed at all. And so look aside - Laravel (bigger) / lumen (easier) - quite affordable php frameworks to get data from data.php, although not. You don't even have to create such a file)

S
Swert, 2020-12-27
@swert-tech

I'm using axios and there is also a Fetch API .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question