7

I have to create a REST API for a mobile application and I don't really know how to begin it. I read some articles and tutorial about REST in general, but I didn't find a complexe API example written in PHP.

So after more researches I choose to use a micro-framework (rather than start from scratch). A full framework like Symfony2 or Zend provide some methods that I will not need, and I think they are too big for. Because I already worked with Silex PHP, I choose it.

But one question stay in my mind : is Silex a good choice to create a (future) big API ?

The API will evolve and could be more and more complexe (understand more URI will be avalaible in future, because we have goal to migrate from SOAP to REST).

Since Silex PHP uses a single file convention, I'm a little scared to use it (because file will be more and more larger, and I supposed with performances falling). Also I would like to cache on server results (additionally with HTTP caching) when necessary, to reduce queries to database (MySQL).

What do you think and what do you advise ? :)

7
  • I would go with Symfony2, but you can also just add MVC to your Silex stack for better code scaling. Commented Oct 8, 2012 at 11:18
  • I thought about Symfony2 and ZF2, but I find them complexes and too large in this case (and I have not a big experience with these two frameworks). But I could be wrong :)
    – user1609268
    Commented Oct 8, 2012 at 12:14
  • Have you looked into Limonade? It's very small for a framework, and Tropo recommends its use with their REST API. Commented Oct 8, 2012 at 12:40
  • I'm not really convinced by Limonade. It seems to be not update since a long time... and its architecture is more particular than Silex (even if both have similarities). Principal problem I see with a micro-framework concerns the Routing. The application will parse all routes before run the right. If I have a lot of URIs (and it will be the case), execution time will be increase. And what about scalability ?... I think, like @ChocoDeveloper said, Symfony2 is more signifiant (I find ZF2 less convenient). But use a full stack framework require more time (learning etc).
    – user1609268
    Commented Oct 8, 2012 at 13:22
  • 1
    I would not recommend to include minor api version in the url, as every time you'll release a new minor update it will broke the client. Istead it's a good practice to use just the major version like [...]/v1/[...]
    – Aram
    Commented May 1, 2013 at 1:14

2 Answers 2

1

Silex is not a bad choice for building out an api service. I would recommend maybe starting with Silex Kitchen Edition for some decent organization and other useful configs and strip out what you don't need. Also, I would look for existing restful projects written in silex/symfony. As far as scalability you should read this post from Igor Wiedler one of the creators of silex.

-9

Silex is a microframework meant to be used in small projects. It's suitable for small websites with low traffic. It is also a good way to introduce yourself into some concepts like dependency injection, without introducing too many abstraction layers. They've recently introduced the target in their website as "single-file apps", giving you a bit of the target scope for the framework.

I think it should be fairly accepted fact that Silex is not suitable for anything big. Silex will not perform badly if your project works, but it will not be the nicest to work with once you start growing, as it will not help you too much. Symfony uses concepts you'll see in Silex and is a full stack framework you can use for bigger applications with lots of bundles, plugins and a big community there to help you.

Edit:

Note I cannot delete the answer as it has been accepted. I haven't used PHP in years now, since then, Silex has changed their approach from "microframework" to being just a library it seems. Whatever the case, the down-voting I believe must come from people involved with the project, probably upset of having created something which didn't take off as they may have hoped.

Just read the product docs, this was a request for an opinion which was given and accepted. I don't think this question belongs to stackoverflow anyway.

5
  • All I can add to that is with Silex there isn't so much configuration to deal with like Symfony, you can just write code very quickly, I would recommend Silex for prototyping and testing, small apps
    – gunnx
    Commented Oct 31, 2012 at 17:37
  • What would you use instead of PHP? And why?
    – tom
    Commented Dec 1, 2012 at 20:59
  • PHP = cheap deploys, cheap starts... with Java you can't get the cheap servers, but if you're gonna have your own servers anyway, Java is easier to work with, it's more efficient in processing, and also something the architecture of application servers like tomcat is much better suited than httpd for such tasks IMO. Of course there's plenty of options, but if you're starting you want to go for the big ones so you get the support.
    – fd8s0
    Commented Dec 3, 2012 at 13:26
  • 1
    What is this tosh? Such a good thing it was deleted...
    – Jimbo
    Commented May 26, 2014 at 17:02
  • if you guys don't like my opinion just post something else... it is a matter of opinion after all, I changed some of my phrasings, I think some people got very sentimental about this
    – fd8s0
    Commented Jul 21, 2014 at 16:01