Articles

The 12 Factor PHP App – Part 3

📁 php

This is Part 3 of a 3 part series: - Part 1: Codebase, Dependencies, Configuration and Backing Services. - Part 2: Build Release Run, Processes, Port Binding and Concurrency. - Part 3: Disposability, Dev/prod parity, Logs, Admin Processes. This series takes the development guidelines specified in…

Read more...

The 12 Factor PHP App – Part 2

📁 php

This is Part 2 of a 3 part series: - Part 1: Codebase, Dependencies, Configuration and Backing Services. - Part 2: Build Release Run, Processes, Port Binding and Concurrency. - Part 3: Disposability, Dev/prod parity, Logs, Admin Processes. This series takes the precepts specified in the 12 Factor…

Read more...

The 12 Factor PHP App – Part 1

📁 php

This is Part 1 of a 3 part series: - Part 1: Codebase, Dependencies, Configuration and Backing Services. - Part 2: Build Release Run, Processes, Port Binding and Concurrency. - Part 3: Disposability, Dev/prod parity, Logs, Admin Processes. In this series we’re going to look at ways of building sc…

Read more...

Definitive Laravel 4 to Laravel 5 Migration Guide

📁 laravel

We like to stay on the cutting edge, so when Laravel 5 was released in February 2015, it wasn’t a question of whether or not we would migrate our 4.x applications across… it was just a matter of when. After a few slightly painful (but successful) migrations, we decided to put together a comprehens…

Read more...

Why Use the Repository Pattern?

📁 architecture

The repository pattern has recently taken on a life of its own in the echo chamber of PHP architecture and development blogs. It seems that just about every PHP developer with a blog has ingested the proverbial [flavoured drink mix](https://en.wikipedia.org/wiki/Drinking_the_Kool-Aid) and written a…

Read more...

Setting the Environment Name in Laravel

📁 laravel

One of the most important things for you to consider when planning the deployment of your application into production is how to handle detecting the “environment.” The environment name is a string identifier that is unique for each deployment environment. Typically, descriptive names such as “prod…

Read more...

New Response types in Laravel using Custom Facades

📁 laravel

Laravel provides some great tools for simplifying the development of web applications. One of them is the Response facade, which allows us to quickly and easily send information back to the requester (browser window in the case of a normal user, third-party application in the case of API access). …

Read more...

PDO for Elegant PHP Database Access

📁 architecture

Speaking very broadly, every computer application is basically a data manipulation tool. The application accepts data from the outside world, performs some transformation on it and then pushes some different data right back out. The data inserted into an application can come from a peripheral devi…

Read more...

A Pattern for Reusable Repository Design in Laravel

📁 laravel

I like the repository pattern (link), but find it tedious in a lot of ways. We employ the pattern because it enables us to break the dependency between our controllers and/or service layer code and the ORM (typically Eloquent). Unfortunately, it usually involves writing a lot of redundant boilerpla…

Read more...

Dependency Management with Composer

📁 php

## What you’ll learn - How to manage dependencies on third-party vendor libraries using Composer - Loading, namespacing and autoloading dependency managed code using Composer’s built-in PSR-0 autoloader - Publishing your own libraries via Packagist ## What is Dependency Management? Web applicati…

Read more...

Managing PHP Environments with Vagrant Baseboxes

📁 devops

One of the most important aspects of setting up your development environment is the notion of **DEV-PROD parity**. This refers to the practice of making sure that the system that you develop an application on is as close as possible to the system that the application is eventually going to run on w…

Read more...

Redirect All Requests to Index.php via htaccess

📁 devops

For one of my website projects I wanted to create a very basic content management system. The plan was to have a header and footer template class, and include these from the ‘index.php’. The bit between the header and footer (‘content’) would then be pulled from another file, depending on the URL. …

Read more...

Securing your web application with Symfony

📁 symfony

## Introduction As a web developer, securing your web applications is one of the most important and complex tasks you’ll regularly undertake. You may need to use some security mechanism to make sure the visitor has valid credentials (authentication) within the domain of your application. You may a…

Read more...

Models made easy with the Doctrine ORM

📁 symfony

Most web applications like to persist things, and as a web developer, you’re going to be spending a good portion of your development time pulling things in and out of databases. If you’ve worked on more than a couple of projects, you know how quickly interfacing with your database becomes a bore. …

Read more...

Creating Forms with Symfony

📁 symfony

As a web developer, forms will either be your favourite thing or the bane of your existence (and sometimes both). But the reality of the situation is that in order to get data from users into your application, you’re probably going to be using a lot of forms. Symfony, being the smart framework that…

Read more...

Symfony Does Validation

📁 symfony

Since the beginning of computing the single most error-prone and unreliable component of the system has been something that isn’t really part of the system at all. Talk to anyone who’s worked in tech support and they’ll tell you the most common problem when troubleshooting computer malfunctions: op…

Read more...

Templating with Twig

📁 symfony

Writing PHP and HTML together is sooo 1998 – which is why Symfony uses the Twig templating language by default. This means instead of writing ugly code like this: <Gist id="2576062" /> … we can use this: <Gist id="2576065" /> Much nicer. Twig not only allows us to use a “friendlier” syntax when…

Read more...

Connecting everything together with Routing.yml

📁 symfony

In this article we’re going to talk about Symfony’s routing system. Because you’ve read our comprehensive dissection, you already know that Symfony uses a front controller (you have read it… right?). This means that all URLs are serviced by a single script – typically contained in the “app.php” fil…

Read more...

Using Logical Names in Symfony

📁 symfony

The intention of Symfony is to make things easier for developers. One of the big pain points when developing large and complex web applications is keeping track of the physical location of classes, templates and assets within your project. Symfony helps us out here by providing logical names for co…

Read more...

Dissecting the Front Controller

📁 symfony

In this article we’re going to get our hands dirty poking around inside the Symfony 2 front controller. Scalpels ready? What’s that? A question? ## What's a front controller? If you’ve worked with a few web applications in your time you’ve probably already encountered the front controller pattern…

Read more...