Search code examples
apisymfonymobilefosuserbundlefosrestbundle

Symfony 2 - FOSUserBundle - how to integrate in API


I work on a new Symfony 2 project. I'm learning this framework at the same time. For the user management, I use the bundle FOSUserBundle. My project works very well, I can login, register, logout and all other commands available.

The thing is that I want to make smartphone app which will use the API of my Symfony app. In the app, the user will have to sign in, or to sign up. Is it possible to use FOSUserBundle methods for API too?

I studied another bundle for making an API, it's FOSRestBundle. If there are not solution, do you think that I will have to create my own users method like :

    /api/login
    /api/register 

Then, inside this method, I redirect to FOSUserBundle methods? I'm just wondering what is the best, and the cleanest way to login, and register with FOSUserBundle from smartphone, so by using API


Solution

  • I used the FOSRestBundle.

    This bundle is very powerful and simple to implement. The documentation is pretty complete.

    The github link of FOSRestBundle here

    Hope that it helps