Ubuntu 16.04 - Install GPG Extension for PHP 7

Below is a script you can run to install the GPG extension for the PHP 7.0 CLI on Ubuntu 16.04. It may work on other distributions and versions of PHP, but I have not tested that. Related Posts Debian 8 - Install GPG Extension for PHP 5.6…

Read this article

Extremely Defensive PHP

Below is a talk from Marco (Ocramius) on extremely defensive PHP. Marco works at a company called Roave (software consultancy), and is an active contributor in th Zend Framework and Doctrine teams. He conveys a lot of great points that I think we could all benefit from. Introduction to speaker…

Read this article

PHP-FPM - Show/Hide Errors

Turning on the display of errors with PHP-FPM is as easy as switching display_errors from Off to On in the /etc/php/7.0/fpm/php.ini file. To make life easier, you can copy/execute the following scripts to do this for you. Display Errors (Dev) SEARCH="display_…

Read this article

Ubuntu 16.04 - Install NGINX with PHP

This tutorial will quickly get you started with deploying an NGINX webserver and configuring it to work with using PHP 7.0. If you want to install MySQL, MariaDB, or PostgreSQL as well, that's easy enough to do separately after/before completing this tutorial. Steps Install NGINX and php-fpm sudo…

Read this article

PHP - Using Traits

Introduction Traits, which were introduced in PHP 5.4, are defined as: Traits are a mechanism for code reuse in single inheritance languages such as PHP. A Trait is intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods freely in several independent…

Read this article

Ubuntu 16.04 - Install PHP SSH2 Extension

Installing PHP with the SSH2 extension for PHP 7.0 in Ubuntu 16.04 is as easy as: sudo apt-get install php7.0-cli -y sudo apt-get install libssh2-1 php-ssh2 -y No need to install through PECL.…

Read this article

Debian 8 - Install GPG Extension for PHP 5.6

Below is a script you can run to install the GPG extension for the PHP 5.6 CLI and Apache on Debian 8. It may work on other distributions and versions of PHP, but I have not tested that. The script assumes you already have Php 5.6 and Apache…

Read this article

Debian 8 - Install PHP 7.1

Using Ondrej Sury The easiest way to install PHP 7.1 is to use prog-exec. prog-exec "23/2" "2649c263665a6224262882b6abb46ad49cc6935654e56a62a1cdfb70c353b02e" Alternatively, you can copy and paste the following script, which is what the previous command downloads and executes. #!/bin/bash sudo apt update sudo apt install apt-transport-https lsb-release ca-certificates -y sudo…

Read this article

Dependency Injection

Anthony Ferrara has a brilliantly simple youtube video explaining dependency injection that I highly recommend. In basic terms, anywhere that you pass an object into another Class's constructor, rather than creating a new instance of that object within the constructor, you are using dependency injection. Dependency injection allows for high…

Read this article

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