Generating Public & Private Keys Using PHPSECLIB

A few tasks that I’ve been working on this weekend have needed public/private key pairs. The very useful phpseclib library provides the tools that you need to generate these within your application.


Making Local Development Faster with Caches for NPM & Composer (Part Two: Composer)

If you’re a heavy PHP user, you’ll most likely be using quite a bit during your development cycles. A quick win in speeding this up is using a local cache for Packagist which means you’re only downloading across your local network instead of across the Internet.

You can run a local toran proxy instance by running this command:

We can break this down a little bit. The volume mount means that we have persistence with our cache and settings. We use port 82 and the hostname of toran.local. This means that we can add the following the to our projects composer.json:

Your local composer will now begin to use your toran proxy instance. You can read more information about the Docker image used here over at the Github repo or on the Docker hub page.



You can read the first part of this series detailing an NPM cache here.


Laravel Blade Stacks

One thing that I often forget about is a nice feature in Laravel that allows you to push scripts or other blocks of code into another part of your templates, so for example:

You can do this multiple times and each one will be pushed on to the stack, when you’re ready to dump and display them, you can dump to view using @stack:

Nothing ground breaking here, but incredibly useful. You can read more about it on the Laravel documentation.

Type Hinting in PHP7

I’m happy that PHP7 has finally been released, I’ve been wanting to correctly return type hint for such a long time. You can now do this comfortably:

But more usefully, you can type hint interfaces to guarantee the classes you get returned (which is actually far, far more useful and beneficial).