Skip to content

Instantly share code, notes, and snippets.


Simon Hamp simonhamp

Block or report user

Report or block simonhamp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View demo.blade.php
// Before
<?php $foo = 'Foo'; ?>
<p>{{ $foo }}</p>
// After
@include( 'partials/foo', [ 'foo' => 'Foo' ] )
View AuthenticatesUsers.php
trait AuthenticatesUsers {
public function getLogin() {
if (view()->exists('auth.authenticate')) {
return view('auth.authenticate');
return view('auth.login');
View Foo.php
class Foo {
use AuthenticatesUsers {
getLogin as login;
public function getLogin() {
// Do my stuff
return $this->login()->with('myvar', 'Hello World');

Keybase proof

I hereby claim:

  • I am simonhamp on github.
  • I am simonhamp ( on keybase.
  • I have a public key ASAHPdAFANeP0F6wuxEQSZ1pduJknbEHdlTnEIcd6CuB8go

To claim this, I am signing this object:

View str_common.php
* Return the common parts from 2 strings.
* @param string $str1
* @param string $str2
* @param bool $from_end
* return string
simonhamp / RemoteArtisan.php
Last active Apr 23, 2019
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 /
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 / list.php
Last active Mar 11, 2020
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 / AppServiceProvider.php
Last active Mar 18, 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;
You can’t perform that action at this time.