Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Building a Micro Markdown API App with Lumen
May 12, 2015 @ 15:35:57

The SitePoint PHP blog has a new tutorial posted showing you how to create a small API service with Lumen, the recently released microframework from the creators of Laravel. Their example service takes in Markdown content and translates it to be returned as JSON.

If you’ve been using Laravel for a while, you know that it sometimes feels a little heavy for a small application or service. For that same purpose, Taylor, the creator of Laravel built Lumen. A small micro-framework built on top of Laravel Illuminate components, it doesn’t load all the components by default like Eloquent, Blade, Middleware, etc, remaining light as it boots up. We will explore all of that this short tutorial. [...] To illustrate a practical use case for the micro framework, we will be creating a Markdown parser API application where the user can submit a Markdown text and get back the parsed content as JSON. I will be using the league/commonmark package from the PHP League.

They walk you through the installation of a Lumen instance (via Composer) and how to build out the folder structure for things like resources, database configuration and views. They then include the code for the route and controller to take in the Markdown content and translate it out to HTML as a first step. Then they use the same functionality and return the HTML result as a JSON document. Also included is a simple few line call with Guzzle to the API to pass in a Markdown file and fetch the result.

tagged: tutorial markdown lumen microframework commonmark translate api microservice

Link: http://www.sitepoint.com/building-micro-markdown-api-app-lumen/


Trending Topics: