-1

I have a server with Symfony RESTful, I want to access from another server with Symfony.

I have seen some examples of php that are accessed with curl or file_get_contents, but I can't find a document for Symfony where it explains the configuration, class organization, bundle to use. There is a lot of documentation on the RESTful API, but not from the querying party. I need to know how the query is made and how the response is handled, without reinventing the wheel.

Can you recommend a document that explains a standard organization or which bundle is usually used?

I am using Symfony 4.4

Apyc
  • 307
  • 5
  • 12

1 Answers1

0

The documentation on how to access a RESTful API is written by the creator of said API. If that's you then only you know what requests to send to what route and what data to expect. You can use the API for your back end and you can have multiple front end applications that connect to it. They would all connect the same way - the way you determine. You can start of by setting up a standard RESTful API. From there it all depends on your needs. That's why you cannot find documentation for this.

Martin M.
  • 431
  • 5
  • 14
  • Thanks Martin, I know I have a concept problem. Setting up a RESTful API is easy, there is a lot of documentation. But from the other server the query to access is normally done with curl? Is there a more elegant and accepted way to make the query and handle the response? My RESTful API is very simple, just create and verify the JWT token for a group of instances. Yes, I know the ip, the route and the data it returns. – Apyc Jun 25 '20 at 09:53
  • 1
    In the case of JWT I think it would be simple. Since you need to send the token with each request (to authorized routes) on your second server you can add a listener/subscriber and attach it. If you want/need to use the controllers to send requests curl would be the simplest way. You can check [here](https://stackoverflow.com/a/9802854/9876136) and adapt it to your case (if you need to analyse the data beforehand). Or if you are using some sort of front end framework it's even simpler - just make the correct requests and retrieve the data. But the business logic would be in the front end. – Martin M. Jun 25 '20 at 11:25