Shiphp The PHP Developer's Guide

Writing a PHP Command Line Script

To write a PHP command line script, you will need PHP installed on your Mac, Windows, or Linux machine, a terminal command line tool like Bash, and a text editor like Sublime. To write a command line script in PHP, open up a new blank file your favorite text editor. Add an opening <?php tag to the very beginning of the new file. On ... Read more

Working with Arrays in PHP

Arrays are widely used in PHP to store groups of data when an object or string will not suffice. Those familiar with other languages may equate PHP’s arrays to dictionaries, lists, collections, or stacks, but essentially a PHP array is a reliable key-value storage system in the language. Let’s look at what an array can do in practice. Creatin... Read more

File Uploads in PHP

A common function for most web applications is uploading and storing files from users. Doing this securely and reliably can be a challenge, but there are a couple options if you’re using PHP. 1. Use a File Upload Service If you want to ensure that your file uploads are securely and reliably stored no matter what web hosting environment you u... Read more

Type Hinting and Return Types in PHP 7

Many developers prefer strongly-typed languages, and critics have often dogged PHP because its weak typing opens users up to errors and vulnerabilities. While PHP is still a “weakly-typed” language (meaning variables can change types throughout the program’s lifecycle), PHP 7.0 sought to give developers more control over how they specify func... Read more

Running a PHP Web App in a Docker Container

If you’re familiar with the process for creating a simple website using PHP, then adding Docker to the mix should be relatively easy. The great thing about using Docker is that you have better portability over your code. Let’s look at a simple Docker command that will host a webpage written in PHP. Our PHP Script index.php Create a file cal... Read more

Running a PHP Script in a Docker Container

If you’re used to running PHP command line applications, adding Docker could be a great way to increase the reusability and portability of your scripts. Docker allows you to run your code in isolated containers rather than on the host machine directly, meaning that even if you don’t have the same version of PHP or extensions installed, you can... Read more

Announcing our First eBook on PHP and Docker

We are excited to announce the release of our first eBook, Building PHP Applications in Docker: A Step By Step Guide for PHP Developers Learning Docker. The book covers a wide range of topics including: Installing dependencies using Composer. Getting data from a third-party API. Saving data to a database. Using a web framework for rout... Read more