I’m a full stack web developer, who takes API seriously. Its been 2 years now and i’m still doing the same steps to create every API i implemented, sure i was automating some stuff using some frameworks who makes things easy, organised and simple starting with Express and Sails, to using Symfony and finally API Platform!
Two months ago -give or take I’ve a bad memory- I was thinking that i hope one day i’ll automate the API design and implementation to be much faster, maybe running a couple of PHP commands to create a whole entities with its relationships and API routes, and expose them, with a well auto-generated docs for entities based on annotations -maybe- .. well that till a friend of mine told me about this awesome framework which he stumbled upon and “we need to check it out, this 100% gonna be awesome” — he said. And he was right, they did the same thing i wanted to do AND MORE.
Enough nonsense, i’m not a good writer anyway. Lets get into installation:
- You need to clone API Platform repo, by running this command
git clone firstname.lastname@example.org:api-platform/api-platform.git
Then while you’re standing on the main root of the repo. run the following command to actually run the platform containers
docker-compose up -d
If you’ve ran into this error or similar
ERROR: for client Cannot start service client: driver failed programming external connectivity on endpoint api-platform_client_1 (7d82cb397e0a882f7474f227541ca43eb804316ece68c8a7dc5ac9af91972202): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use
that actually self explanatory it means that port 80 is in use in your current OS, so check which service is using it and kill it or better change its port. In my case this service was apache so a simple sudo service apache2 stop was enough to do the trick.
Everything should be working now,
docker-compose up -dshould be full with green done statements indicating everything is working. You should be able to head to
http://localhostfirst then navigating to
https://localhostand see the cool API Platform PWA client.
You’re now ready to create your API and consider following API Platform awesome documentation its really helpful and they have a cool walk through that will help you get to know it more.