Reza Lavaryan, Jun 29

Disco with Design Patterns: A Fresh Look at Dependency Injection

We build a basic framework with a new dependency injection container called Disco, explaining all the confusing concepts along the way. Join us!
Adam Bard, Jun 28

Heroku Alternative: Deploy Apps with Dokku on DigitalOcean

Adam Bard shows how to get small, low-traffic projects up and running with Dokku on DigitalOcean, creating a Heroku-like experience without the cost.
Bruno Skvorc, Jun 28

Sourcehunt: PHP7-Only Alternative to Laravel, HPKP, and More

This sourcehunt features a PHP-7 only alternative to Laravel, input validation, HPKP, strict PHP object signatures, and more.
Bruno Skvorc, Jun 27

Can Symfony Apps Be Fast on Vagrant? Let's Check with SuluCMS!

In this tutorial, we go through some effective performance hacks for developing Symfony apps on Vagrant virtual machines
Miguel Ibarra Romero, Jun 22

Using Halite for Privacy and Two-Way Encryption of Emails

Miguel implements the Halite library in a sample email sending application, to get symmetrically encrypted emails going for full communication security!
Angela Molina, Jun 20

Spreading the Word on WordPress Security

Did you know that WordPress powers a third of the web, and a popular target for attackers? This week we chat to Chris Burgess on WordPress Security.
Daniel Sipos, Jun 20

Your Own Custom Annotations - More than Just Comments!

Danny teaches you how to build Doctrine-style PHP annotations for your own custom projects!
Bruno Skvorc, Jun 15

The PHP Application Environment

This is an excerpt from SitePoint's recent book on PHP Application Environments and get getting started the right way. Enjoy this preview!
Francesco Malatesta, Jun 13

Laravel Doctrine - Best of Both Worlds?

Francesco introduces Laravel Doctrine, and builds a sample app with it - come learn about this powerful ORM + Framework mix!
Daniel Berman, Jun 08

Monitoring WordPress Apps with the ELK Stack

Daniel shows us how we can apply the ELK stack to WordPress for advanced monitoring and error logging - never stare at confusing logs again!
Bruno Skvorc, Jun 06

Composer Global Require Considered Harmful?

Installing composer packages globally can cause some dependency conflicts. Here's how to get around it with the help of a new, alternative tool.
Bruno Skvorc, Jun 04

Quick Tip: Local Development with Opera, Nginx 502 error

A quick solution to getting rid of the 502 Nginx error when developing locally with Opera
Christopher Pitt, Jun 03

Hacking the Fitbit - Emulating a Pager for Twitter DMs!

Chris makes his cheap Fitbit vibrate on new Twitter DMs - emulated pager AND a silent wake-up alarm? WIN!
Bruno Skvorc, Jun 01

Nitpicking over Code Standards with Nitpick CI

Nitpick CI is a service with a singular purpose - making sure your Github PRs respect the PSR-2 code standard. In this post, we'll put it to the test
Bruno Skvorc, May 30

Sourcehunt: Conferences, Oauth2 in Slim, Static Analyzers, Etc.

Another sourcehunt is here! This time, we're featuring conference apps, personal project managers, oauth2 helpers, and more!
Bruno Skvorc, May 27

Phinx - the Migration Library You Never Knew You Needed

Bruno demonstrates the use of Phinx, a framework-agnostic database migration package helping you write database-independent and versionable database changes
Christopher Pitt, May 25

Finding Differences in Images with PHP

Chris Pitt was building a testing suite which compares screenshots of websites before/after. For that, he needed image diffing. See how he did it!
Jehan Fillat, May 24

Please: Automated CMS and Framework Installs in Vagrant

Jehan introduces Please, a bash script for automating the installations of many CMSs and Frameworks by configuring them automatically into your Vagrant box.
Younes Rafie, May 20

Localizing Dates, Currency, and Numbers with Php-Intl

Younes take a more detailed look at php-intl, this time focusing on localized dates, currencies, numbers, calendars, and more
Scott Molinari, May 18

Benchmarking: Can AppServer Beat Symfony's Performance?

Scott revisits Appserver and benchmarks it against Symfony to dispel the rumors of bas performance. Does he succeed? Tune in to find out!
Younes Rafie, May 16

Localization Demystified: Php-Intl for Everyone

Confused by php-intl and localization in general? Don't be! Younes explains what it's all about and guides us through some examples!
Wern Ancheta, May 13

We're Building a Marvel Catalog Reader! Avengers, Assemble!

In this tutorial, we're going to take a look at the Marvel API, a tool provided by Marvel for developers to get access to the 70-plus years of Marvel comics data.

Marvel logo

First, we'll walk through the steps in which one can acquire the keys needed to make requests to the API. Then, we'll look at the tools we can use to test out the API. Finally, we're going to build a website that uses the API.

Signing Up

The first thing we need to do is go to the Marvel Developer Website and click the Get a Key link. We'll then be provided with the public and private key which we can use to perform requests to the API. If you plan to use the project in production, you can also add your website's domain name to the list of authorized referrers. This provides a security layer in case you accidentally push your public and private keys to Github.

Important Notes Regarding the Use of the API

For limits and rules, please see the attribution, linking and rate limits page of their documentation. Also be sure to read the Marvel API Terms of Use if you're planning to use the API in production. I've summarized it below:

  • Beware of the API rate limit. At the time of writing of this tutorial the rate limit is 3000 calls per day. That's applicable to all the endpoints.
  • Always attribute Marvel as the source when displaying API data and images. Marvel recommends the use of this text: Data provided by Marvel. © 2016 Marvel.

Playing with the API

The API comes with an interactive documentation which allows you to easily test all the available API endpoints.

There's information on the data one can expect:

expected data

... text fields to specify the different parameters to be submitted for the request:


... error status codes:

error codes

... the request URL, response body, response code and the response headers:

request and response

Do note that the request URL won't actually return anything if you access it outside of the API testing tool. This is because it lacks the required parameters for the request. At the bare minimum, you'll have to supply the public key, the current unix timestamp, and an md5 hash of the timestamp, and private and public key combined.

$ts = time();
$public_key = 'your public key';
$private_key = 'your private key';
$hash = md5($ts . $private_key . $public_key);

Once you have those, only then can you perform a request to the API:

$query_params = [
    'apikey' => $public_key,
    'ts' => $ts,
    'hash' => $hash

//convert array into query parameters
$query = http_build_query($query_params);

//make the request
$response = file_get_contents('http://gateway.marvel.com/v1/public/comics?' . $query);

//convert the json string to an array
$response_data = json_decode($response, true);

We'll take a look at this in more detail when we get to the section where we start making requests for the app that we'll be building.

Daniel Berman, May 11

How to Process Server Logs

Daniel Berman explains what the ELK stack is, how to install it, and how to make it analyze the logs of the typical LAMP stack
Reza Lavaryan, May 09

An Overview of PHPUnit 5 - What's New? What's Coming?

Did you miss the PHPUnit 5 train? Hop on board and find out what's new!