PHP Articles
I do not like time zones. They’ve been a fairly regular pain point in my career, especially early on. There was even a time when I built something and totally forgot that time zones existed and well, it was a mess. For the most part, time zones don’t cause me
[…]
Going through some of my old lists of blog post ideas this weekend. While it’s not something I’ve needed for a minute, it’s still something worth taking about. How to set an authorization header when using PHP’s wonderful file_get_contents() method. Similar to an old post of mine talking about specifying
[…]
I’m no stranger to the nuances of testing against different version of PHP and PHPUnit, but my previous issues were related to the environment itself. Recently I ran into an issue with different syntax between versions of PHPUnit, specifically assertRegExp() being deprecated, which was throwing an error. Not only was
[…]
While it may seem counter intuitive to have a test that doesn’t have any assertions, PHPUnit’s unique method of sharing data between tests can put you in a situation where you have a test that just doesn’t need to actually test anything, and simply returns some data. In those scenarios,
[…]
Gone are the days of stitching together disparate services in an effort to create a solid continue integration and deployment pipeline. GitLab has had it’s Runners for a while and recently GitHub stepped into the mix with their Actions offering. Because of this, using external services like Travis CI or
[…]
With my recent exploration of GitHub Actions, I’ve had to figure out things that I’ve already figured out with other systems like GitLab Runners and Travis CI. One such thing is conditionally running steps. For things like code coverage, I’m only interested in sending off the coverage report to the
[…]
Recently I decided to finally tackle the ever growing S3 bucket for the niche social network I run. The reason it’s ever growing is because I never implemented any sort of hard deletion logic. At one point, I was planning to move the images over to soft deletions, but never
[…]
Recently I’ve been putting time into rebuilding the server infrastructure for Holiday API. This has included hardening the system to be more fault tolerant and building out a new cluster of web servers. The biggest improvement was [finally] introducing a continuous deployment pipeline to complement the existing continuous integration flow.
[…]
Usually around a holiday I will do a post that’s somehow related to the holiday. Seemed kind of silly to do a post on how to calculate Independence Day in the United States since it’s pretty straight forward. It always lands on the 4th day of the month of July.
[…]
With the release of inbound webhooks for CrowdSync workflows last week, it seemed fitting to do a write up on how to POST to a webhook. So what is a webhook, anyway? The Wikipedia definition is that webhooks are “used-defined HTTP callbacks”. Kind of a stuffy definition if you ask
[…]
The other day I was checking out what folks are querying to get to my site. Of course a ton of people get here looking for VPS comparison, but what surprised me was the volume of queries for “PHP routing”. Back in 2015 I had posted a basic page rounding
[…]
Recently I was updating my PHP Lorem Ipsum library in an attempt to get it testing on HHVM on Travis CI alongside the other versions of PHP I was testing against. Incidentally, the last time I had worked on the project, I had to work out some kinks with older
[…]
Upgrading to PHP 7.x (7.0 or 7.1 as of the time of this writing) is just as easy as it is to upgrade to PHP 5.6! Before we install PHP 7.x, I would recommend getting your system up to date: sudo apt-get update Next you will need to add the
[…]
By request from Bill Martin, an abridged history of my relationship with the bastard child of programming languages, PHP. Ahh PHP. I love it. I hate it. For well over a decade, I slung PHP day and night. I got into PHP at the tail end of version 3. Prior
[…]
As I’ve been building a system that is driven primarily by CSV files (because it’s easier to use Google Sheets than it is to build out an admin section) I’ve had to get creative. Recently I found myself working with a CSV file that’s around of 3000 lines of data
[…]
Ran into a scenario this weekend where I needed to take a sub-document from Mongo but I needed it in an array in PHP. Reading the data from Mongo with PHP was simple and won’t be discussed. What I’d like to talk about is taking the BSONDocument that Mongo returns
[…]
Recently I set out on an interesting journey. I wanted to build programming libraries for my API, HolidayAPI. Some of the languages I know like the back of my hand. Others, have never even touched them before. Before you start sending me hate comment, I am fully aware of Swagger.
[…]
Typical of PHP, it’s very easy to get the day of the week from a date, but they also provide the data in multiple format. Three in fact. The first, and arguably the most straight forward is to get the textual name of the day of the week. <?php echo
[…]
Before PHP 5.3, finding the difference between two dates was a bit of a pain. Convert the date strings to UNIX timestamps (if they weren’t already), subtract them, and then divide the result until you had each of the components (seconds, minutes, et cetera). As of PHP 5.3+ you can
[…]
Validating that an email addresses ain’t what it used to be. I remember writing simple regular expressions that worked out really well. These days there are a bajillion TLDs with more being added all of the time. Something I started doing is checking that the domain of the email being
[…]
Checking if a string contains a character could be accomplished easily with a regular expression or you can use the built-in PHP functions. To check if a string contains a character of a specific case you can use strpos. $haystack = 'This is my haystack that we shall check' $has_A
[…]
There’s many ways to skin a cat, or generate a color. You could randomize a number between 0 and 16777215 then convert it to hex: $rand_color = '#' . dechex(mt_rant(0, 16777215)); Or you could do what I like to do, just md5 a random string and grab the first 6
[…]
Sometimes, you may want to run code all of the time. Other times, you may want to run code some of the time. This is how garbage collection in PHP works. Based on your configuration for gc_probability and gc_divisor, garbage collections runs a fraction of the time (defaulting to 1/100
[…]
I hope you’re really fucking pissed right now. I hope you go thermonuclear on the comments box. Why? Because it really just proves how right I am about how stupid you are. You let some silly blog post get under your skin. Thing is, I really didn’t know what to
[…]
Project Honey Pot is one of my favorite services. They offer an API that allows you to pull information on an IP address. This comes in very handy when vetting traffic coming to your website. I discovered the service a few years back after realizing that I had some spammers
[…]