Dejan Stosic

Full Stack Web Developer

Github | Twitter

Minimalistic REST API in PHP with JWT authentication (the no framework approach)

See full project on GitHub


We all love those awesome frameworks like Laravel or Symfony or whatever your choice is, they have tons of useful stuff and they really do make our lives easier. But sometimes you want to build a small project and the idea of using a framework with 736 dependencies doesn’t seem so appealing all of a sudden. However you still want to do stuff the right way and you wonder if it’s even possible without all those things?

I’ve found myself in such situation quite a few times and after some experimentation i came to the simple yet effective solution presented in this post.

With this approach you’ll have all the nice things like dependency injection, routing, validation, JWT authentication etc. in 750 kilobytes with all dependencies installed.

I’ll try to be as beginner friendly as possible without making this too long *, so feel free to follow along even if you don’t know what’s REST or if you never wrote an API.

Also, i’m using the “Top-down” approach in this tutorial, so don’t worry if some things don’t make much sense at start as we’ll start with the big picture, but as we get to the end, you should be able to understand what’s going on.


PHP imap_open() too slow? Here’s a potential solution

The handy PHP function for connecting to IMAP servers, the imap_open(), caused nothing but trouble for me for the past few days.