programming Archive

Using _.intersection for deep many to many filter

Sometime you might find yourself needing a fast way to do a complex match on property from an array of objects under a property (confused?) Let's say I have a collection of objects as such: [crayon-5b2e06e7e0548447252673/] I want to have a fast way to get all items that are in group ID: 1...
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

Worthy of Distribution: Angularjs patterns

Feel like you've gotten 'over the hump' on getting AngularJS to do what you want? Check out the video below to help save yourself from being overly analytical for your project structuring and avoiding common pitfalls (and general javascript pitfalls) for moving on to the "next level" for AngularJS development.   https://www.youtube.com/watch?v=UlvCbnKAH3g...
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-5b2e06e7e095b845657045/] It will now look like this in PHP 7: [crayon-5b2e06e7e0961728492823-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

angular-ui-router – IE8 and nested states

Just a quick tip, If you still have to maintain compatibility with IE8 (< AngularJS 1.3) - and you're using angular-ui-router for nested views, the documentation for nesting states says you should use "<ui-view />" for your template for an abstract parent state: Remember: Abstract states still need their own <ui-view/> for their children...
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

Note to self: Digest hashing and crytpological hashing are birds of a different feather

Over decades of enhancements in computer science, there's always a revolution going on in cryptography and hashing, MD5, SHA1 yesterday, SHA256/512 today.As a programmer, it's sometimes hard to avoid the back and forth talk about how algorithm A is inferior to algorithm B, and forget how hashing can be used...
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

MySQL – multibyte cheat sheet for conditionals

This is basically a short cheat sheet to launch some ideas for comparisons/matching with multibyte characters.Connection collation of utf8_unicode_ci and charset of utf8 - Table + data and server: [crayon-5b2e06e7e15fb143453112/][crayon-5b2e06e7e1601013243442/][crayon-5b2e06e7e1603689754249/][crayon-5b2e06e7e1605065324457/]Check out the behavior of the following queries:[crayon-5b2e06e7e1607337424346/][crayon-5b2e06e7e1609501701634/]Other resources:MySQL's character sets and collations demystifiedMySQL charset documentationCharsets and joins (good gotcha to...
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