Stefan B
Stefan B

Reputation: 11

Symfony 2 Project with external data from API

i want to connect a new symfony 2 project with an existing CRM REST API. So i want users to see their CRM data in my project. What is the best way to get the data for my entities (Users, Contracts, Tickets etc.) from the external API?

I'm not that familiar with this framework but that are my thoughts:

  1. Create entities
  2. Create Service for the external API requests to the CRM 3.? Connect the entities with the corresponding records in CRM ?
  3. Create caching system so that data is only updated every 1 or 2 hours.

Is there a better way and how do i realize point 3. ?

Thanks and best regards

Stefan

Upvotes: 1

Views: 889

Answers (1)

Alexandru Furculita
Alexandru Furculita

Reputation: 1373

There are a few ways to do this:

  1. The easiest one is to not import your data in Symfony, but to get it with Ajax requests from your CRM and add it to your Symfony app. You can use Backbone or ReactJs or AngularJs etc, for that. In this case Symfony will manage everything except the data that is taken from your CRM

  2. The other way: create entities for all the data types you will import. Create a service that will manage the data import from CRM. Create a command that will run this service and attach it to a cronjob. In your import service use Guzzle to take the data from your CRM and use JMSSerializerBundle to transform the imported data into entities. You may use this bundle: https://github.com/misd-service-development/guzzle-bundle for this job, it does the integration of Guzzle into Symfony and with the JMSSerializerBundle.

Hope it helps

Upvotes: 1

Related Questions