18

I really like working with SailsJS (http://sailsjs.org). Especially because it automatically generates a RESTful CRUD API. However, working for small clients, I don't always have the opportunity of working in a NodeJS environment. Mostly their webapps run on an Apache (PHP/MySQL) server.

My question: Is there any framework that provides an automatically generated RESTful CRUD API? If not, what is the best approach to write it myself?

I'm aware of frameworks that handle routing, however I'm looking for something that automatically generates CRUD API (based on blueprints or linked to the database tables).

For speeding up the development process and keeping my code clean I also like ORM's. It would be nice if I could link the automatically generated API to the ORM schema/blueprint. So once again, what is the best way to approach this?

I couldn't find any frameworks that provide this. Hope you guys can help me out.

Thanks in advance!

Dennis

Dnns
  • 2,614
  • 3
  • 18
  • 16
  • I wrote something like that, see this [blog](https://www.leaseweb.com/labs/2015/02/simple-php-rest-api-script-mysql/). – mevdschee Oct 18 '15 at 19:47

6 Answers6

10

In some way the best and easy Php Framework for write API and RESTful application is

Slim Framework

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs. slimframework.com

hello world:

<?php
$app = new \Slim\Slim();
$app->get('/hello/:name', function ($name) {
    echo "Hello, $name";
});
$app->run();
gabrielem
  • 560
  • 5
  • 13
7

This is a restful api framework that can get you started pretty fast http://luracast.com/products/restler I've used it in the past. very fast and lean.

however developing APIs is fairly easy. some other light frameworks are Slim Php.

Zend is really heavy.. but you can pretty much extend their zend Rest class and write your own which will be the "easiest".

Shahin Khani
  • 199
  • 4
  • 14
1

If you don't know PHP Take a look at http://davss.com/tech/php-rest-api-frameworks/ If you want to learn PHP and write your own, you have a long way to go from JS, but if you're ambitious, read Matt Zandstra - Objects Patterns and Practice, and have a look at PEAR.

user138720
  • 141
  • 8
  • I do know PHP, actually better than JS. I don't want to reinvent the wheel, that's why I ask if there is a framework that fits my needs. And if not, I don't ask how to write it myself, but what is a GOOD (maybe best) approach to do so. – Dnns Oct 25 '13 at 11:22
1

I did wrote a little script that uses Propel ORM + SLIM.

It is based on AngularJS (For the javascript side).

You can adapt it for your needs. If you know well PHP, you might find the code ugly.

https://github.com/a-lucas/angjs-propel-slim

Ant
  • 1,812
  • 5
  • 22
  • 39
0

Take a look at Symfony2 - it is a great framework that has many helpers / generators for what you describe.

http://symfony.com/

It is also a microframework - so you can take components and factor them into your own framework if you go that route.

If it is too heavyweight for your needs then Silex - built using symfony components may also be of interest

http://silex.sensiolabs.org/

BillyBigPotatoes
  • 1,330
  • 11
  • 23
  • 3
    Symfony indeed is too heavyweight. I'm aware of microframeworks like Silex. Both do not provide (as far as I know?) an automatically generated CRUD API, which I'm looking for. – Dnns Oct 25 '13 at 10:11
  • 2
    Actually Symfony2 provides CRUD which works using GET/POST/PUT/DELETE methods, and you will just need to reconfigure it to return json instead of html. – mikayel ghazaryan Oct 25 '13 at 11:31
0

Here is a poll in sidebar http://davss.com/tech/php-rest-api-frameworks. I confirm that SLIM is very nice and simple