ZF2 Modules, Services, and Events

In this post, we are going to explore a few design patterns and architectures that reach into the heart of any ZF2 based application: The ServiceManager, the EventManager, and the Module architecture.

When it comes to building an application with ZF2, your application will be constructed with one or more modules, each of them providing services for other modules to consume. Likewise, these modules can trigger events which allow additional modules to react to things happening within the application at large.

To get started, we will begin with an introduction to the ServiceManager in ZF2.

Read More

Actually MVP

Introduction

In the startup world, there is a lot of talk about building Minimum Viable Products (MVPs). At this point, the concept has become so well-accepted that it has almost become a kind of unquestioned dogma. Yet there is a lot of disagreement about what MVP is exactly, and how to carry it out. Many people in the software industry assume that they know what MVP means, and claim to be using the process, but their production workflow tells a different story.

When it comes to building software, it is often tempting to take an approach akin to building a skyscraper: write the blueprints, obtain the necessary prerequisites, then build it to spec. But software is a quickly shifting market. A businessperson may think she knows what the market wants, and plan and begin a project to meet that desire. But by the time the product is built, the needs of consumers have often morphed in a direction that she could never have foreseen.

In this post, we'll take explore some common misconceptions about MVP, some different ways to approach building one with software, and how to best use this tool if you're the CEO or CTO of a startup, a product manager for an established company, or a consultant.

Read More
Learn about Engine Yard
Try Engine Yard for your Ruby or PHP Apps

Testing async emails, the Rails 4.2+ way

Say you're building an app that needs to send emails. We all agree that we should never block the controller, so async delivery is the way to go. To achieve this, we'll move our email sending code outside the original request/response cycle with the help of an asynchronous processing library that can handle jobs in the background.

How can we be confident that our code behaves as expected upon making this change? In this blog post, we'll look at a way to test it. And we'll use MiniTest (since it ships with Rails) but the concepts presented here can be easily translated to RSpec.

The good news is that since Rails 4.2, sending emails asynchronously is easier than ever before. We'll use Sidekiq as the queuing system in our example, but since ActionMailer#deliver_later is built on top of ActiveJob, the interface is clean and agnostic of the asynchronous processing library used. This means that if I hadn't just mentioned it, you wouldn't be able to tell, as a developer or a user. Setting up a queuing system is a topic on it's own, you can read more on getting started with Active Job here.

Read More

Composer & Continuous Integration

Automated testing is widely used to identify regressions in libraries and applications in different environments and with varying configuration.

No matter whether you employ Test-Driven Development, have a set of acceptance tests from Behaviour-Driven Development, or use a suite of functional tests to ensure your application works as you expect, the goal of automated testing is to quickly provide engineers with reliable information on potential problems.

Continous Integration (CI) is the practice of continuously (and automatically) testing every change a developer makes. So automated tests become an integral part of the development process providing direct feedback on changes made.

The Need For Testing

Traditionally, PHP projects did not have build processes. PHP is not a compiled language, so there was no need. However, because of advancements in front-end development, build processes are a common aspect of modern web projects. From minified and modularised JavaScript, CSS pre-processors, and so on. Because of this, using Composer to manage your PHP libraries is usually only an addition to the existing build process. While PHP libraries may not previously have needed a build process, testing their integration with dependencies now requires installing the dependencies through Composer.

Read More

How to use Environment Variables on Engine Yard with Envyable

If you're building an application in this day and age, chances are that you're following methods from the Twelve-Factor App. One of these is to store configuration in the environment versus hard-coding them in your application.

With Engine Yard, it's typically recommended that you write some custom Chef to modify your environment. If you’re only dropping in configuration files, like the secrets.yml file that Rails uses, Chef is a bit of an overkill. An easier way is to use the Envyable gem to load environment variables when the application is started.

Before we look at Envyable, let's see some environment variable usage in a typical Rails application.

Read More

CHECK OUT OUR CURATED COLLECTIONS

Look through our specially curated posts to get focused, in-depth information on a single topic.