While playing around with AngularJS, I decided to create a simple PHP app/framework to test API handling. Here’s what I’ve used so far:

  1. PHP Slim as back end framework. For this project, I didn’t need a user management or heavy dependency injection, but instead a solid REST API. PHP Slim lets you bootstrap smaller PHP applications very fast and is easy to learn. When I tried to receive POST data sent by AngularJS I found out, that you can’t fetch them by using $app->request->post(), instead you have to use json_decode($app->request->getBody(), true). Next time I should read the documentation more carefully.

  2. Eloquent ORM. This is a core element in Laravel and very neat. I preferred this over Doctrine (would have been an overload for this project) and Propel (just wasn’t stable with PHP Slim). When using Eloquent make sure that you set either public $timestamps = false in your model or use created_at and updated_at columns in your tables to make it run with PHP Slim. I used the second option and have to say: Eloquent rocks!

  3. Twig. In my example app only one view is rendered by the back end so far: The main HTML template—all other views are handled via AngularJS. So why did I use Twig? I don’t know, what kind of projects I might do with this project and Twig guarantees that if in the future I want to render templates via back end, everything is prepared.

  4. JavaScript is currently provided by CDNs, so Bower and Grunt are not in use. I will implement them soon.

I don’t know if the structure of the project makes sense, but I will hopefully find out soon. Try it out!

Update 06/17/2015

Since I didn’t update the project for some time, I removed candyGular from Github.

Marco Raddatz

Marco Raddatz


Marco Raddatz Private blog of Marco Raddatz from Hamburg, Germany. Back to Overview