php Archive

PHP Interface rant

This isn't my first rant about interfaces (which are finally receiving a due adjustment). I haven't tested it, but don't believe I've seen anything pertaining to interface inheritance, look at the following use case for example, which fails in current PHP 5.6: [crayon-5bf43783c845f675319221/] There are some benefits to doing this, however as you...
Read More

Laravel/Lumen vs Symfony/Silex a corporate perspective

YAPFC. Yet Another PHP Framework Comparison. I'm judging Silex and Lumen through their bigger brothers, Symfony 2 and Laravel 5. After doing some extensive research, re-evaluating the PHP framework atmosphere, two frameworks and their respective "mini-me" counterparts seem to rule the seas. In this post I'm simply sharing my opinion of Laravel and Symfony...
Read More

A PHP bug – really? (custom session handlers)

It's not often I ramble about PHP, since it's my bread and butter. But after perusing the RFC notes to get up to speed on the PHP 7 pipeline, I found this: https://wiki.php.net/rfc/session.user.return-value That bug has been around for how long? I'm amazed folks with pitchforks haven't come out on that one...
Read More

PHP 7 Roundup – implicit ‘array to string’ conversion

Feast your eyes upon this: https://wiki.php.net/rfc/array-to-string If you've been in the trenches for a long time, chances are you've been bitten more than enough by the implicit array to string conversion as such: [crayon-5bf43783c886c993681487/] It will now look like this in PHP 7: [crayon-5bf43783c8872383801210-i/]    ...
Read More

PHP 7 Roundup: Chainable ternary awesomeness.

Feast your eyes on this: https://wiki.php.net/rfc/isset_ternary This eliminates quite a bit of 'noise' and 'fluff' use in any display logic, it's a new ternary operator that allows you to quickly set a default without doing the isset() dance. This has a limited affect if you use a templating engine like Twig, but it's...
Read More

How to use PHPUnit installed by composer in PHPStorm

Ever wonder how to properly use those packages installed from the require-dev section of composer.json? Ideally you'd integrate them with your IDE, or perhaps set up your system path to access it via vendor\bin\phpunit - If you use PHPUnit, take a quick look at this on how to properly set up...
Read More

PHP 7 Roundup: RETURN TYPES!

Many years ago (in 2011) I wrote "interfaces are worthless". For the most part they have remained mostly worthless for me as typically a superclass of sorts has proven to be a better solution for taxonomy and enforcing the exact typing rules I have criticized interfaces in PHP for in...
Read More

Composer and getting to vendor/bin

Want to stop typing 'vendor\bin\toolname' to access tools like PHPUnit, phpcs, etc when installed through composer? It's a simple process really - merely add "vendor\bin" into your PATH variable and profit! (as long as you're running the command from the project root). https://www.youtube.com/watch?v=UrME91Ta_aY...
Read More

PHPCS custom standards and PHPStorm integration

At about 6 minutes long, I threw together this screencast to show a method to involve your custom PHP CodeSniffer standards into your project workflow when using Composer. Essentially it covers the convenience of putting your standards into a Composer package and adding a wrapper to 'extend' the PHPCS shell/batch...
Read More

Using Logstash to log SMTP/email bounces like a boss

I've recently worked on a customized emailing suite for a client that involves bulk email (shutter) and thought I'd do a write up on a few things that I thought were slick. Originally we decided to use AWS SES but were quickly kicked off of the service because my client doesn't...
Read More

PHP 5.5 RC1 released – what I’m most excited for..

Where I work we have unfortunately had to skip the 5.4 release of PHP; the release cycle between PHP 5.4 and PHP 5.5 was pretty darn fast and we never got around to replacing APC. We've finally got everything up to speed to adopt 5.5 when it hit's stable release. I...
Read More

A safer approach to using Monolog’s SocketHandler

Monolog is perhaps the most popular logging library out there for PHP at the time of this writing. It has a lot of support and a nice balance of features. Unfortunately I have one gripe to make about the rather closed implementation of the SocketHandler , er, handler?   The problem with the...
Read More

PHP: array_merge(array $a, [ array …]);

Wait, PHP wants to array_merge an array with... itself? Take another look at this: array_merge(array $a, [ array ...]); If you're good at reading API's - you'll see how ... odd this is. Seeing as I just got nipped in the butt by forgetting to have another array to merge into -...
Read More

Zend Studio + PHPUnit upgrade: A faster method

As a counterpart and refinement of my previous how-to, this update shows how to update the PHPUnit library faster than using the symlink method: View in HD!  Subscribe in a reader ...
Read More

Mercurial (hg) checkstyle hook, at last!

As far as I can tell, there's not much in the lane of check style hooks for Mercurial.There's a lot of hits for git and SVN, but not much for Mercurial.Check it out in my 'hg-checkstyle-hook' bitbucket repo.I thought I'd share my (imperfect) rendition of a Mercurial checkstyle hook. It's...
Read More

PHP’s APC – Don’t back yourself into a corner

We heavily rely on running multiple instances of code where I work. At any given time several of us have several copies/branches of the site code configured to run from various spots on our development server.A path we have gone down with APC's user variable caching is merely one of...
Read More

Disable PHP 5.4’s built-in web server, while keeping CLI …

Administrators: Don't get blind-sided by PHP 5.4's CLI web server!I've gone over a similar issue like this before regarding the likes of git/hg. While those are developer tools and are less likely to be present on a production machine.PHP 5.4 is jumping on the bandwagon to include a 'cute' little...
Read More

PHP Vulnerability – DJBX33A – Hash table collisions

Trickling through my RSS feeds this morning was an article with quite the topic "PHP Vulnerability May Halt Millions of Servers". In a nutshell: A modest size POST to almost all PHP versions in the wild (Sans 5.3.9+) are in danger of an extremely simple DoS. The vulnerability exploits the PHP internal...
Read More

All of your PHP code is going to look silly! PHP 5.4, here we come!

No, not as in 5.4 will make you write stupid code. As in it will make all pre-5.4 attempts to maximize re-use through crazy inheritance chains look ridiculous compared to what traits will deliver.I already have a sense of dread of being a year into PHP traits looking at not-too-old...
Read More

Upgrading to PHPUnit 3.5 on Zend Studio

Here's a quick clip I made to show those who hankering to have an updated PHPUnit plugin for Zend Studio.I hope this video is obsoleted soon so others don't have to endure the annoyance.View in HD! Subscribe in a reader...
Read More