Silex CORS provider for OPTIONS (preflight) requests
One part of using Silex as your framework when building an API that can be a little fiddly is CORS issues when making requets from javascript apps. I’ve started using a very simple solution for this that seems to be easier and faster than most providers. The issue here is that the requesting application is making an OPTIONS request to see whether it can make the actual request and by default Silex won’t return the response the JS app is hoping for.
Continue ReadingCode Katas
A code kata is a small programming challenge aimed at improving your programming and problem solving skills. The idea is you regularly spend 15 to 30 minutes solving a small problem. There has been some debate over whether these are actually useful, especially for more experienced developers. My view is that if you approach them correctly, then they can be a valuable method of improving both your knowledge of a programming language and your problem solving skills.
Continue ReadingGetting started with UML class diagrams
UML or the Unified Modelling Language was developed to help IT professionals a common design language abstracted from specific platforms or programming languages. This article will get you up and running with UML in the form of class diagrams. The main building blocks As you can probably guess, the bulk of our class diagram will be made up of classes, abstract classes and interfaces. The first box is a standard class.
Continue ReadingCode smells in PHP - Boolean parameters
This isn’t one of the most common code smells you’ll hear of, but I certainly think it deserves to be on the list. To me, boolean parameters in functions and methods generally indicate that the function in question has a split inside where the code can go one of two ways, often doing more than one thing! Lets have a look at what might happen when you come across with a method with a boolean parameter.
Continue ReadingCode smells in PHP - Don't repeat yourself
Code smells allow us to spot traits in our code that may not stop it doing its job, but may indicate deeper rooted problems with the design of the code. I like the concept of code smells because it gives me a simple list of tells I can easily spot in my code which help improve the maintanability of that code. In this series we’ll go through some common code smells, why they’re bad, how to spot them and how to remove them from the codebase.
Continue ReadingGetting started with moltin payment gateways
This article is an overview of how to receive orders using the moltin API. We’ll go through the order process, how payment gateways work and get Stripe set up so that we can receive both live and test payments. If you need more information on payment gateways, you can check out the moltin payment gateway documentation and to get help, the Slack support channel. Payment gateway providers act as the middleman to receive payments from your customers and pass the money on to you.
Continue ReadingInclude a composer package as a git repository
Sometimes, you want to see how a composer package affects the including project as you make changes. But making changes to the package, committing, pushing and then pulling down the updated package can be a painful process. Luckily, composer allows us to specify that we’d like to pull down the full repository for specific packages. We are then able to modify this repo and see our changes instantly before committing anything.
Continue Reading