alexeymezenin / laravel-best-practices

Laravel best practices
11.44k stars 2.38k forks source link

What PHP to JS package is recommended? #116

Open augustjanse opened 3 years ago

augustjanse commented 3 years ago

The part on getting data to JS says this:

The best way is to use specialized PHP to JS package to transfer the data.

What package would that be?

carlos-mora commented 3 years ago

Depending on what schema are you going to use to transfer data. In my case, using GraphQL, I have Lighthouse on the Laravel side, and Apollo on the other end.

augustjanse commented 3 years ago

In that case you're accessing the data with an AJAX style request. Is that what the guideline is saying to do? I don't think that's very clear.

alexeymezenin commented 3 years ago

@augustjanse when I wrote this, I meant packages like this one (this particular one is very old). There were plenty of those.

I guess there are better ways to pass data to front-end in 2021. I haven't worked with front-end for a long time, so I can't help here.

I'll keep this issue open so JS guys could share their thoughts about the problem.

augustjanse commented 3 years ago

Alright, thanks! The upstream to the fork you linked looks like it is being maintained, so it looks like a reasonably good alternative. I thought it was kind of hard to find information about it, though, so it may still be dubious as a best practice. Interested in hearing from others what they think.

A few relevant SE questions: https://softwareengineering.stackexchange.com/q/421991/328116 https://softwareengineering.stackexchange.com/q/126671/328116 https://stackoverflow.com/q/23740548/1729441 https://stackoverflow.com/q/415868/1729441