API Documentation with IODocs
Iodocs is a node.js application (which is fun for a PHP developer. Most developers write a bit of JS, but this one hasn’t). You describe your API and all its methods in JSON, and then iodocs presents an interface for you to enter API keys, add parameters to each request and press the “try it!” button. This makes your API call and shows you the results on screen, which seems like a great way to demonstrate what all the various parameters do!
Do Open Source with Git and Github
Often I find absolutely competent programmers, who aren’t involved in open source, either because they don’t know how to approach a project, or because they just aren’t sure how the process even works. In this article we’ll look at one example, the conference feedback site joind.in, and how you can use GitHub to start contributing code to this project. Since so many projects are hosted on github, this will help you get started with other projects, too.
The tl;dr Version for the Impatient
- Fork the main repo so you have your own github repo for the project
- Clone your repo onto your development machine
- Create a branch
- Make changes, commit them
- Push your new branch to your github repository
- Open a pull request
This article goes through this process in more detail, so you will be able to work with git and github projects as you please.
Continue reading
PHP for Drupalistas
This spring Emma Jane and Lorna Jane were chatting about PHP and Drupal and workshops and came to the conclusion that Drupal developers were not necessarily equipped for Drupal 8. With all of the Drupalisms in the Drupal code, it can sometimes be difficult to implement code that is both a Drupal best practice and a PHP best practice. While there are many workshops on how to teach PHP developers how to Drupal, there were no workshops teaching Drupal developers how to PHP. Until now!
My theory is that most developers working with CMSes like Drupal think they don’t know much PHP … but of course they actually know quite a lot! The newer versions make more use of OOP and new PHP features, but nothing that’s really rocket science (although the symfony components are very nice). This course is a chance for us to give a more solid grounding to those skills that developers just pick up along the way, and give some time to master those skills in a safe environment. Continue reading
Posting Raw Data with Curl
I put the data into a separate file, data.txt
and then used curl to direct that data at my local URL:
curl -X POST http://localhost/app/test.php --data @data.txt
I find this approach useful for testing, but since I had to look up how to do it, I thought I’d put it here for reference!
The Quest for a Payment Gateway
I recently carved out some time to correct this situation, and fell into an absolute pit of confusion when I tried to figure out what my options even were. My requirements are that my customers are global, I am UK-based, people will set up a regular subscription, and I don’t have (and I think I don’t want) a merchant account at this point. I’m not PCI compliant and have no intention ever to attempt that. This post is an attempt to round up some things I found out along the way. Continue reading
Skills Allied to PHP
In October, I’ll be delivering a tutorial at the mighty PHPNW Conference which contains very little PHP. Why? Because I think, as developers, it’s our other professional skills that suffer. As a consultant, I work with lots of different teams, and it is very rare for code to be the problem (and the one time it was, it wasn’t the only problem!).
In web development, our biggest challenges are not writing code, we can do that. But getting the code safely from one place to another, with many people’s work preserved, having our platform(s) correctly configured and understanding how to use them, making use of the tools in the ecosystem which will help us improve the quality of our code; these are the big challenges we face, and that’s why I proposed this workshop and why I think all these topics are important. Continue reading
Validating Email Addresses in PHP
$email1 = "nonsense.something@dottiness"; // not a valid email
$email2 = "[email protected]"; // valid email
$clean_email1 = filter_var($email1, FILTER_VALIDATE_EMAIL); // $clean_email1 = false
$clean_email2 = filter_var($email2, FILTER_VALIDATE_EMAIL); // $clean_email2 = [email protected]
The Filter extension was new in PHP 5.2, but is one of the unsung heroes of the language. It’s rare for me to ever describe one approach as the “right” way to do something – but for validating data, Filter really is excellent, offering both validating and sanitising filters and generally making it super-easy to clean up incoming variables. Many of the frameworks offer equivalents, and I’m sure many of those are wrapping this too.
Two Years of Trading
Installing PEAR Packages Offline
However I’m now in a situation where I might need to install PEAR packages with a connection that may or may not be working, and I’m not sure exactly which packages I might need, so I wanted to know whether I could use PEAR as my packaging tool even when I wasn’t able to reach the usual channels. And guess what? I can! Continue reading