Slim3 - Use Middleware to Check User Is Logged In

One of the most common tasks I have to perform in developing web applications is check that the user is logged in and redirect them to the login page if they are not. Also, there are certain routes, such as /login, and /register that should not incur a redirect because…

Read this article

Debian 8 - Setting up PHP For Aerospike

This tutorial will show you what you need to need to do in order to start interfacing with an Aerospike database with PHP scripts. If you haven't done so already, install PHP and composer. sudo apt-get install php5-cli # Install composer curl -s https://scripts.programster.org/scripts/21?output=raw…

Read this article

Getting Started With Using PostgreSQL in PHP

The first thing you need to do is install PHP and support for PostgreSQL. For ubuntu 16.04 you would need to run: sudo apt-get install php7.0 php7.0-pgsql -y If you haven't already installed a PostgreSQL server and configured it with a password and to allow remote connections,…

Read this article

RabbitMQ Exchanges With PHP

This tutorial will show you how to setup RabbitMQ in terms of an exchange, rather than for a queu as demonstrated below: The source code for this tutorial can be downloaded from Github. Related Posts RabbitMQ Job Queue With PHP Deploying RabbitMQ With Docker What is An Exchange? An exchange…

Read this article

RabbitMQ Job Queue With PHP

This tutorial will show you how to deploy and utilize a job queue in PHP using the RabbitMQ server we deployed through Docker. Why Use Job Queues? Job queues allows your infrastructure to gracefully cope with massive fluctuations in demand without having to scale up/down rapidly. For example, if…

Read this article

PHP - Install YAML Support

If you need to generate YAML files from PHP (perhaps for Docker Compose), then it is probably easiest to install the YAML Data Serialization PECL package. This tutorial will show you how to do that on Ubuntu. Ubuntu 16.04 With PHP 7.0 sudo apt-get install php7.0-dev php-pear…

Read this article

PHP Gotchas and Tips

Here are some PHP observations that I have been caught out with and am posting so I don't get caught again. This post will grow over time as I find more bite-size nuggets. Gotcha: Array Merge Guess what the output to this code will be: <?php $lookup_table = array(…

Read this article

PHP Time/Date Cheatsheet

Converting User Input $timestamp = strtotime("01/01/1999"); $timestamp = strtotime(915148800); $timestamp = strtotime("1st January 1999"); You now have the unix timestamp (number of seconds as an integer, since 1st January 1970) PHP considers date strings with - to be English, and dates with / to be American. # This is the…

Read this article

PHP - Converting Data for Google Charts

I find it annoying that for a line graph, Google wants the data in this format (javascript): var data = google.visualization.arrayToDataTable([ ['Year', 'Sales', 'Expenses'], ['2004', 1000, 400], ['2005', 1170, 460], ['2006', 660, 1120], ['2007', 1030, 540] ]); In PHP form this is equal to the following (before we run JSON…

Read this article

Laravel Route Jenkyness

If you start a new Laravel 5 project, you may notice that Netbeans doesn't know what certain items are. For example if you open the routes file at /app/Http/routes.php you will see the following: Route::get('/', function () { return view('welcome'); }); Now if you double click…

Read this article