F
F
fury20062020-03-12 14:28:47
Backend
fury2006, 2020-03-12 14:28:47

How to work with PHP backend using Vue?

Hello.
For me, full-stack development is just a hobby so far and there is one question that worries me.
What is the correct way to work with the backend (in PHP) using vue in the project?
So far, my idea is the following:
- For example, we use Laravel (which includes, as I understand it, vue)
- We use axios to communicate with the backend - We
use only the API for communication, and inside them we already do all the calculations and additional all PHP functions
- For the safety of the API, we do with OAuth authorization

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dima Pautov, 2020-03-12
@fury2006

Yes, everything is as you described.
As for OAuth, of course, I would not say that it’s super mandatory, sometimes you can simply resort to a jwt token. OAuth provides many more advantages besides security, for example, as a single server for user authorization for many projects. As a matter of fact, any social networks make it possible. If you have a simple project and it does not contain any very important data, then you can do without OAuth. It's just my opinion))

D
dmx00, 2020-03-13
@dmx00

I will add that if you do not need authorization through the social. network, do not use tokens (in any form of OAuth jwt, etc.) Use sessions, yes, yes Regular built-in sessions, the only difficulty in Laravel is that you need to get csrf (for this you need to add one path to middleware exceptions), if not authorization and this problem is not.
If you want in a fashionable way, that is Laravel Airlock , where everything is done and the documentation is written, although I personally think that if the sessions are suitable (spa on the same domain as the back), then there is no need for the package.
Any tokens are more or as dangerous as sessions, and also more difficult to work with. When choosing tokens, you need to understand exactly why you need it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question