Software Development Articles and Tutorials


Live Reload Go Projects with wgo
April 19, 2024

Live Reload Go Projects with wgo

Building web apps in Go is extremely rewarding. However, as Go’s a compiled language, to see changes, you need to restart the app. Needless to say that’s quite tedious! With live reloading, it doesn’t need to be.

Restrict HTTP Request Methods in Go 1.22
April 11, 2024

Restrict HTTP Request Methods in Go 1.22

Restricting HTTP request methods, when working with net/http prior to Go 1.22 was a little complicated. However, that’s all changed. Now, it’s pretty trivial. In this short tutorial, I’ll show you the new approach.

Restrict HTTP Request Methods in Go 1.22
April 11, 2024

Restrict HTTP Request Methods in Go 1.22

Restricting HTTP request methods, when working with net/http prior to Go 1.22 was a little complicated. However, that’s all changed. Now, it’s pretty trivial. In this short tutorial, I’ll show you the new approach.

Debug Go Code with Visual Studio Code
April 27, 2024

Debug Go Code with Visual Studio Code

Recently, I started debugging Go code using Visual Studio Code. Some minor hiccups aside, it was pretty trivial to get up and going. This is the short version of what you need to do to get started.

Understanding Go's Empty Interface
April 12, 2023

Understanding Go's Empty Interface

Recently, while working with the Twilio Lookup API, I had the opportunity to properly learn about Go’s empty interface. During the process, I realised that I didn’t understand it properly, so took the opportunity to do so. Today, I am going to step through what it is and how simple they are to work with.

Restrict Allowed Route Methods in Go Web Apps
April 1, 2023

Restrict Allowed Route Methods in Go Web Apps

It’s incredibly easy to build web apps and APIs using Go’s net/http package. All you really need to do is to specify a route and its handler. But, how do you restrict the methods that routes can accept? In this short tutorial, I’ll show you how.

Go Interfaces Make Development and Testing Easier
April 21, 2023

Go Interfaces Make Development and Testing Easier

Substitutability or the Liskov Substitution Principle (LSP) is a concept that I’ve tried to adhere to for some years when writing code. It’s beneficial for many reasons, but particularly when testing, as it can indirectly force you to write code that is more testable. Recently, I’ve started appreciating how it works in Go, and will step through how in this short article.

Install PHP's Imagick Extension on macOS
April 4, 2023

Install PHP's Imagick Extension on macOS

Homebrew makes installing PHP and so many other great tools on macOS a breeze; almost as easily as a Linux package manager. But how do you install the Imagick extension? In this short post, I’ll show you the shortest way to do so.

Getting Started with Visual Studio Code
April 23, 2023

Getting Started with Visual Studio Code

Recently, I’ve been spending a lot of time writing Go code and, honestly, didn’t want to pay for a license for a commercial text editor or IDE. I asked around for recommendations and nearly everyone said “Use VS Code!”. So that’s what I started using and this is my initial impressions after about two weeks with it.

Set Environment Variables in PHP with PHP dotenv
April 12, 2023

Set Environment Variables in PHP with PHP dotenv

There are a number of ways to set environment variables in PHP. But the approach I use most often in development is a wonderful package called PHP dotenv. In this tutorial, I’m going to step you through how to install and use it.

Build Your Own Software Packages
April 27, 2023

Build Your Own Software Packages

I recently refactored parts of a web application for an upcoming Twilio tutorial into three open source packages. Here’s what motivated the decision to do so, and why I think you should create them too.

Setup Step Debugging in PHP with Xdebug 3 and Docker Compose
April 10, 2021

Setup Step Debugging in PHP with Xdebug 3 and Docker Compose

In versions of Xdebug before version 3 setting up step debugging for code inside Docker containers has often been challenging to say the least. However, in version 3 it’s become almost trivial. In this short tutorial, I’ll step you through what you need to do, regardless of the (supported) text editor or IDE you’re using.

How to Use a CSRF Token in a Mezzio Application
April 2, 2021

How to Use a CSRF Token in a Mezzio Application

No matter how small your web app may be, security is essential! In this tutorial, you’ll learn how to add a CSRF token in forms used in Mezzio-based applications, to prevent attackers from being able to force your users to execute malicious actions.

How to Manually Create a Mezzio Application
April 13, 2020

How to Manually Create a Mezzio Application

If you want to build applications in PHP — from one-page apps to enterprise-grade applications — PHP’s Mezzio framework is a excellent framework to choose. In this tutorial, which is an excerpt from my new book, Mezzio Essentials, I’ll show you how to manually build an application in Mezzio.

Goodbye Master Zend Framework. So Long. Farewell.
April 8, 2020

Goodbye Master Zend Framework. So Long. Farewell.

It’s with some sadness, that earlier this week, I wished a fond farewell to the biggest blog I ever created, Master Zend Framework. Given that, it only feels right — and responsible — to talk about what motivated the decision to close the blog, and what the future holds for the blog’s content.

The Essentials of Learning Java
April 16, 2020

The Essentials of Learning Java

If you’re getting started learning Java, whether because you want to or you have to, I want to help you out, as I’m learning Java again too. In this post, I set out what I think you need to know to get started with it, or what your first few steps will likely entail.

Updating Zend Expressive Essentials to Mezzio Essentials
April 2, 2020

Updating Zend Expressive Essentials to Mezzio Essentials

As Zend Framework is now rehomed at the Linux Foundation and has also been rebranded, I’ve decided to update my book and course on Zend Expressive. In this post, I’m giving some background about the journey of creating the book, insight into the progress I’ve made, and what lies ahead.

A Short Introduction to Postman
April 10, 2020

A Short Introduction to Postman

Debugging requests can be a time-consuming process. However, there’s a tool that makes doing so a lot simpler. It’s called Postman. In this tutorial, I step you through its core features and show you how to use them.

How to Run Tests in PhpStorm
April 3, 2020

How to Run Tests in PhpStorm

PhpStorm offers so much functionality. From syntax highlighting to Docker integration, it’s an extremely comprehensive tool. However, have you ever thought of using it to run your unit tests? In this article, I step you through running tests, from an entire suite to an individual test.

Fix a Commit History With Git Interactive Rebase
April 28, 2019

Fix a Commit History With Git Interactive Rebase

Git interactive rebase is a powerful tool that can help you fix up your commit history to make it more meaningful, professional, and maintainable. In this post, I step through what it is, how it works, and when you should — and shouldn’t — use it.

Command-Line Productivity Hack - ctrl+x+e
April 21, 2019

Command-Line Productivity Hack - ctrl+x+e

There are lots of tips, tricks, and ideas around for hacking your command-line productivity to make you more efficient. However, in this post, I’m not going to show you something that’s super in-depth, ultra-detailed, or talk about an app that you have to install, ctrl+x+e.

How to Set Up PHP Debugging with PhpStorm, Xdebug, and PHPUnit
April 3, 2019

How to Set Up PHP Debugging with PhpStorm, Xdebug, and PHPUnit

Still using var_dump to debug your PHP code? Stop! While var_dump can be convenient, it’s a very blunt approach. In this article, I’ll show you how to set up proper debugging with PhpStorm, Xdebug, and PHPUnit, and give you a modern, sophisticated debugging experience.

Why Is My Website So Slow?!
April 27, 2019

Why Is My Website So Slow?!

Is your website (or web-based application) not performing like you expect it should? Not sure why or what to do about it? Then come learn about some key things you can do to have your website perform properly.

4 Git Command-Line Tips for Greater Productivity
April 23, 2019

4 Git Command-Line Tips for Greater Productivity

Git, despite still being a bit terse, is extremely powerful version control software. However, because it’s so powerful, it takes time to learn. In this post, I’m going to show you four small techniques to help you use it more effectively.

Are You Too Wedded To Your Text Editor?
April 10, 2018

Are You Too Wedded To Your Text Editor?

I’ve been a proud VIM user for years — dating back as far as 1999 — but especially so, since I pushed myself to learn it properly a few short years ago. However, I wonder if I’ve become too wedded to it. And I’m keen to find out if you are too.

April 26, 2018

What Are Delegator Factories and Why You Should Use Them

Ever wanted to dynamically expand the functionality of an object which you retrieve from your dependency injection container, based on different needs, yet without creating messy, hard to maintain configurations? Then you’re going to want to know about a powerful new technique - called Delegator Factories.

April 16, 2017

Easy Git Interaction with OhMyZsh and Git Extras

Git is known to be incredibly terse, though it has improved in recent years. What’s more, there’s a plethora of commands that you need to remember. So, why not learn about OhMyZsh and Git Extras and make your life with Git easier!

April 25, 2017

How to Create a Zend Expressive Module

Ever thought of creating a Zend Expressive module, one that either scratches an itch or allows you to use a set of related functionality across multiple Zend Expressive projects? I created one recently and share how I did it with you in this three-part series.

Vim - The Distraction Free Editor
April 20, 2017

Vim - The Distraction Free Editor

A little while ago, I took to Twitter in a sense of jubilant excitement announcing that VIM was THE distraction-free editor. As it’s been quite some time since, I honestly don’t remember exactly what it was that motivated me to do so.

Visual Debt. Really?
April 14, 2017

Visual Debt. Really?

Recently, Jeffrey Way dateed what’s become quite a controversial video in the PHP community on Laracasts, discussing a concept called Visual Debt.

The Composer Command-Line Essentials
April 29, 2016

The Composer Command-Line Essentials

How well do you really know Composer? Do you just know composer install, update, and require, and some of the composer.json configuration? Or do you really know it? In this series, you’re going to take your skills to the next level; starting with the command-line.

Becoming a Polyglot Developer (again)
April 10, 2016

Becoming a Polyglot Developer (again)

I’ve been developing software in PHP for a long time. But I recently decided to return to my polyglot roots, developing in multiple languages on a regular basis. The question is, which language, or languages, are the right ones to learn and use.

April 22, 2016

How To Use Laravel’s Eloquent ORM with Zend Expressive

Laravel’s Eloquent ORM isn’t likely the first one you think of when using Zend Expressive. You likely think of Zend\Db or Doctrine. But, with a little bit of work, it’s possible to use Eloquent with Expressive. Today’s tutorial shows you how - step-by-step.

April 5, 2016

What I Learned Building a Zend Expressive Application

Zend Expressive is an excellent framework for building modern applications; whether micro or enterprise-sized applications. But that doesn’t mean that it’s the easiest to get up to speed with. Today I’m going to share with you what I’ve learned, building applications using it.

April 23, 2016

How to Simplify Development with the Repository Pattern

In a recent application I found that I was too bound to a database as the application’s data source and wanted to decouple from it as much as possible, whilst using the least amount of effort. During research into the required changes, I came across an excellent pattern which gives a lot of flexibility, yet which doesn’t require a lot of code - it’s called the repository pattern.

April 18, 2016

How to Edit Consistently Using EditorConfig

When working with other developers on a project, editor and IDE differences, whilst not fatal, can be annoying, and even violate group coding standards. Put an end to that by using EditorConfig.

April 9, 2015

Introduction to Zend Expressive (Part 2)

Over the last number of months the Zend Framework team’s been hard at work on Zend Framework 3. And there are major changes afoot. In this 2-part series, we look at one of the core components - Zend Expressive.

April 2, 2015

Introduction to Zend Expressive

Over the last number of months the Zend Framework team’s been hard at work on Zend Framework 3. And there are major changes afoot. In this 2-part series, we look at one of the core components - Zend Expressive.

Enforcing PSR 1 & 2 in PHPStorm
April 19, 2014

Enforcing PSR 1 & 2 in PHPStorm

As software developers you should use coding standards. In today’s post, learn how to enforce the PSR-1 and PSR-2 coding standards with PHPStorm.

April 22, 2014

Howto Handle External Form Element Dependencies with FormElementManager

Zend Framework 2, like all great PHP frameworks, provides thorough infrastructure for creating forms in your application. Whether that’s form objects, form elements, fieldsets, validation groups or that they interact with so many other components in the Zend Framework 2 default libraries. But how do you handle external dependencies?

April 27, 2013

\Zend\Db\Sql - Creating Joins and Unions with Ease

In part two of the \Zend\Db\Sql\Select series, we create inner, outer, left and right joins as well as union queries with ease. Come learn more about building queries simply, effectively and easily in your every day applications with Zend Framework 2.

April 26, 2012

6 XPath Queries to Boost Your Performance + A Bonus Tip

When you’re working with HTML day in and day out, very often the same types of tasks come up repeatedly. Whether you’re generating content to be displayed with PHP or jQuery, whether it’s server or client side, it’s not an easy task. You Need a Helping Hand!

April 15, 2011

Rename uploaded files with Zend Framework

Recently I was asked how to rename a file with the Zend Framework that used a Zend Form and Zend File element. They key requirement was that it should not be a hack or a kludged solution. So I thought I’d write a quick post to provide a simple example on how it was achieved.

April 9, 2011

The Zend Framework Bootstrap made simple (Part 3)

Ok, we’ve established that with the Zend Framework, we need to do a bit more work than some of the other frameworks to get up to speed - but that’s not necessarily a bad thing - right?! But it can be a bit tedious and it’s something as professional developers, we want to automate away. So we’ve been addressing in this series how to do just that with a custom, extendable bootstrap class.

In the first part of the series we laid the foundation of our custom bootstrap class by creating a custom class directory structure, adding its namespace to the application ini and modifying the default application bootstrap so that it extends from it and had a look at the first component - caching.

Then, in the second part of the series, we built on the foundation laid in part one by creating plugin resources for the routing table, application navigation and the database connections - these being some of the most common tasks, usually, associated with a web-based application.

In this, the third and final part of the series, I’m going to finish up by looking at application placeholders and surprise, no not logging as originally promised, but pagination. As an added extra, we’re going to be using a key feature of Zend Application to make it a breeze.

April 2, 2011

The Zend Framework Bootstrap made simple (Part 2)

In the first part of the series, you’ll remember that we laid the foundation of our custom bootstrap class by creating a custom class directory structure, adding its namespace to the application ini and creating our custom bootstrap file that our application bootstrap will extend from.

After we did that, we put in the first but arguably the most important plugin resource – caching and stored it in the application registry. In this post we’re going to be building on that work and adding in three new plugin resources: routing, navigation and databases.

April 27, 2011

The Zend Framework Bootstrap Made Simple (Part 1)

When you’re creating a new project with the Zend Framework, unlike other frameworks, you need to do more legwork. This isn’t necessarily a bad thing, but it can sure slow you down when you’re trying to plough through a project.

I really enjoy using it, as it has a very well structured approach – and I like structure – it clearly lays out a file-system structure for modules, controllers, actions, forms, models and so on. It has good, but basic, tooling, allowing for modest project initialisation. But despite all this, it still requires a healthy investment on our part to get a proper foundation in place to use it productively.

In a recent project I encountered this situation and felt that I mustn’t be the only one to do so. As I plan to keep using Zend Framework I want to work around this situation and get as much productivity out of it as possible right from the get go. But how to do this?

Bootstrapping

Well the primary focus for me is bootstrapping. It provides the majority of the core services that every project needs, from routing, data source connections, authentication, authorisation, navigation, caching and so on. So it stands to reason that it’s a good place to start. So I want to cover what should go in to a good working bootstrap.

April 8, 2011

Zend Form - Multiple Submit Buttons

Let me describe said situation for you; The user has a list of items and they’ve chosen to delete one. Given such a volatile action, you want them to doubly opt-in and confirm that they want to do this.

The last thing you want your user to feel, after they’ve clicked the delete link, is “NO WAAAAAAIIIIT! I didn’t mean to do that”. So the user clicks &’delete&’ and is directed to a confirmation page (which is rendered with Zend Form). There are two buttons on the page; the first is “Delete Item”, the second “Cancel”.

If the user clicks either button, the form submits to itself, where the value of the button clicked is determined. If the user clicks “Delete Item”, then the deletion is carried out, deleting the item from the datasource. If the user clicks “Cancel” the user is returned to the list of items they were previously viewing, the item is not deleted and the user is provided a message, confirming the non-deletion.

April 23, 2011

Extending Zend Auth - A Zend Config Adapter

So in the last installment of this series, I provided an introduction to Zend_Auth, Zend_Auth_Adapter_Interface and Zend_Auth_Result and how to implement Zend_Auth_Adapter_Interface to implement a basic test adapter that can be used as a mock object in your testing.

If you missed it, check it out now, then come back and we’ll continue on. If you’ve already read it, then let’s continue now.

As I indicated last time, whilst being a perfectly valid implementation, the Test adapter was rather basic and didn’t do very much. Like all good testing, you need flexibility and options. So in this installment, we’re going to build an adapter based around Zend_Config. This will lead quite nicely in to the last part in the series which uses the wonderful MongoDB as the underlying resource for the adapter.

April 20, 2011

Scalable Logs with ZeroMQ and Zend Framework

Do you want a scalable, high performance PHP application that logs everything in an intelligible manner; in a manner that you can use now, tomorrow and three weeks from now? It’s so possible! In a series of posts, I am going to show you how to put it together using Zend Framework, ZeroMQ and Hadoop.

April 17, 2011

Extending Zend Auth — The HowTo Series

Zend Auth, if you want to secure a Zend Framework app, along with Zend Acl, it’s essential. But do you know what it is? Do you know how to use it? Do you know how to extend it? Through this series I’m going to show you how to do all three.

April 14, 2011

Internationalizing PHP Applications With TMX

phpMagazin recently did a good job of covering Zend_Translate; specifically what it is, how it works and four of the basic translation adapters; those being Array, CSV, Gettext and Ini. However, what they didn’t cover was what I think, is one of the best choices of adapters that Zend_Translate has; which is TMX.

April 9, 2011

Zend Framework and mongoDB – Getting Started Quickly!

This is a mini-post showing you how to get up and running with mongoDB and Zend Framework using a series of third-party libraries, including Shanty-Mongo library. To be honest, it’s rather trivial, but sometimes it can be frustrating trying to find a simple, concise, reference on how to do it, specific to just your needs.

April 27, 2011

11 Reasons Why a PHP Framework is Better Than Raw PHP

After stating our 11 Reasons Why A PHP Framework is better than Raw PHP, here’s 11 Reasons Why A PHP Framework is better than Raw PHP It, often, has a solid community of professionals developing and supporting it It’s, often, coded to an exacting, mature, coding standard It has a solid development history, reviewed by many eyes It has defined methods of doing repetitive things quickly and simply You’re not on your own and call fall back on people for support It’s, often, simple to link in with existing 3rd party libraries – quickly and easily You’re working within clear constraints and development concepts You can bring in developers already experienced with using and deploying it There are tried and true practices for deploying it There are tried and true practices for testing it Frameworks carry brand and industry recognition What do you think?

April 20, 2011

11 Reasons Why Raw PHP is Better Than a framework

Here’s My 11 Reasons Why Raw PHP is better than a Framework It’s faster as it doesn’t have the framework library overhead It can be cleaner, lacking legacy cruft You can craft it exactly as you want it You’re not bound by someone else’s rules or concepts You can add in as many or as few 3rd party libraries as you choose You can write to your own standard It is portable You can license it as you choose You set the standard by which it is judged You build the philosophy of the project The work is all yours to live or die by What do you think?

April 6, 2011

Zend Framework — 10 Must Dos

The Zend Framework, whilst a great tool, is often slighted for being big and bloated.  Now I’m not contesting that, but it does have a heck of a lot going for it. So if you’re going get the most out of it, then you need these 10 tips.

April 24, 2011

Zend Framework, a Truly RAD Framework!

Like any profession or trade, you can spend years refining your craft; always looking for the path of least resistance; the path of greatest simplicity, which leads to your goals in the shortest time and the least amount of effort. Especially in software development, you try to simplify and automate as much as you can. Not only do you save unnecessary time, but you get to devote your energies to the most meaningful aspects; the areas that bring greatest productivity and satisfaction to you and your client or employer.

April 25, 2010

Writing a Secure, RESTful Service in Zend Framework (Part 2)

In this article, a follow up to writing a secure, Restful service with the Zend Framework, I’m going to cover the HTTP status codes that you should use, where and when. The reason for this is that they’re a fundamental aspect of the interaction with the service. You get this right and you will make it so much better for clients to use your service; you get it wrong and you may only have a few users and they may do a lot of work for very little gain.

April 7, 2010

Writing a Simple Blog With Zend Framework and MongoDB

I’ve been using mongoDB and Zend Framework to make a simple, replicatable filesystem. As it went well, I thought that I could quickly apply what I’d done to create an ultra-simple blog system. Read on to find out all about it.

April 5, 2010

How to Write a Secure RESTful Service in Zend Framework

So you’re up with the RESTful buzz but you’re concerned about security; as you should be! So what do you do? Well, like all good OOP practitioners, you don’t reinvent the wheel. As Steve Jobs said, “Good artists create, Great artists Steal”, or borrow in our case. So let’s look at the Amazon S3 model and implement that with our framework of choice - Zend Framework to protect your RESTful services.

April 19, 2010

JSON, XML, RSS, CSV - it's all a ContextSwitch away!

Do you love the variety of formats that you can publish and subscribe to in this veritable golden-age of computing we’re enjoying? Same here. Whether it’s JSON, XML, RSS, Atom, CSV or even Excel format, there’s just so much choice.

The challenging thing is that though there’s so much choice of format, there are also so many demands to use them - ALL. So what do you do when your boss, client, friend, family-member (whom you’re the technical support person for) requests this for their blog or site?