Posts tagged #laravel

Run and stop multiple long-running commands from Bash with a trap

by Liam Hammett · 7 minute read · #bash #laravel #cli

Sometimes when working on a project, I’ll always want to run a handful of commands at the same time, some of which may return when they’re done, others might be long-running, like watchers or services actively exposing ports.

This is something that might seem simple to do with a basic Bash script at first, but what if your script has multiple processes running side-by-side and you want to be able to stop them all at once too?

Here we’re going to take a look at how we can achieve this with Bash traps and the single-ampersand operator.

Read more…

Laravel Blade Helpers

by Liam Hammett · 3 minute read · #open-source #laravel

Laravel’s Blade templating engine offers a ton of convenient directives you can use to make your view files beautiful and abstract anything that may be too complex or verbose to live inside HTML. It even gives a really handy way to add your own custom directives using the Blade::directive(…) method.

However, the callback in custom directives only receives a single parameter - the raw string expression from the view file. It seems to be rare that developers actually parse the contents of the expression itself within the directive, opting instead to pass the entire expression as arguments to a helper function or a method on another class. For example:

BladeHelper::directive('uppercase', function($expression) {
    return "<?php echo strtoupper($expression); ?>";
});

Read more…

Black Friday 2018 Deals for Laravel Developers

by Liam Hammett · 6 minute read · #laravel

It’s that time of the year again, and over the next few days there will be some awesome deals in all sorts of areas - retail and tech especially. As a Laravel developer, there’s a lot of goodies to get your hands on for some insanely discounted prices!

Here I’ll try to sum up some of the great deals you might want to get your hands on.

Laravel Nova - 30% off

Read more…

Throttle Simultaneous API Requests with Laravel

by Liam Hammett · 2 minute read · #open-source #php #laravel

Laravel comes with a handy ThrottleRequests middleware out-of-the-box that blocks users of an API from being able to send more than a particular amount of requests within a defined amount of time.

This is extremely useful for preventing an API from being abused by spammed requests, but isn’t suitable for every use case.

What about an API call that takes a lot of limited processing power, or performs an action that simply can’t be running twice at the same time?

Read more…