Skip to content

Instantly share code, notes, and snippets.


Simon Hamp simonhamp

View GitHub Profile
simonhamp / ScheduleListCommand.php
Created Jan 6, 2021
Laravel: Back-port the schedule:list command
View ScheduleListCommand.php
namespace App\Console\Commands;
use Cron\CronExpression;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Console\Scheduling\Schedule;
class ScheduleListCommand extends Command
simonhamp / WebhookController.php
Created Jul 8, 2020
Handling Typeform Webhooks in Laravel
View WebhookController.php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class WebhookController
public function create(Request $request)
View StachePrimeCommand.php
namespace Statamic\Addons\MyAddon\Commands;
use Statamic\API\Stache;
use Statamic\Extend\Command;
class StachePrimeCommand extends Command
simonhamp /
Last active Apr 23, 2019
Some quotes and their sources

"A lot of times, you open up some code for something simple like this, and you find that it is just a massive tangle of unnecessary structure and indirection."

Casey Muratori 2014-05-28 (Retrieved 2018-05-18)

"Frameworks are not tools for organising your code, they are tools for organising your mind."

Rich Harris Code Camp 2019 (Retrieved 2019-04-23)

simonhamp / AppServiceProvider.php
Last active Oct 22, 2020
Laravel: Str::csvToArray macro
View AppServiceProvider.php
namespace App\Providers;
use Illuminate\Support\Str;
class AppServiceProvider extends ServiceProvider
public function boot()
simonhamp / VersionMatcher.php
Created Jan 18, 2018
A simple SemVer parser/matcher
View VersionMatcher.php
class VersionMatcher
protected $specificity = 'major';
protected $originals = [];
protected $current;
protected $target;
protected static $padDigits;
simonhamp / BaseModel.php
Last active Mar 25, 2020
Eloquent: Simple Model Event Handling
View BaseModel.php
namespace App;
use Illuminate\Database\Eloquent\Model;
class BaseModel extends Model
* Override the default boot method to register some extra stuff for every child model.
simonhamp / list.php
Last active Jun 15, 2021
Using list() in foreach in PHP
View list.php
$items = [
['field' => 'field1', 'values' => [0, 1, 2, 3, 4]],
['field' => 'field2', 'values' => ['cat', 'dog', 'horse']]
foreach ($items as list('field' => $field, 'values' => $values)) {
// can use $field and $values here now!
simonhamp / RemoteArtisan.php
Last active Feb 10, 2021
RemoteArtisan: A way to call another Laravel/Lumen application's artisan command from the context of the current application.
View RemoteArtisan.php
namespace App;
use Dotenv\Dotenv;
use Illuminate\Support\Str;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
class RemoteArtisan
simonhamp / AuthorizationTest.php
Created Dec 10, 2017
Laravel Testing: Ensure your controllers enforce authorization
View AuthorizationTest.php
namespace App\Tests;
use Illuminate\Support\Facades\Route;
class AuthorizationTest extends TestCase
public function setUp()