Skip to content

Instantly share code, notes, and snippets.

View renalpha's full-sized avatar

Jason Hoendervanger renalpha

View GitHub Profile
@renalpha
renalpha / MenuComposite.php
Last active May 14, 2019 11:21
Composition pattern - Menu
<?php
namespace Exdeliver\Causeway\Domain\Entities\Menu;
use Exdeliver\Causeway\Domain\Common\Interfaces\RenderableInterface;
use Illuminate\Contracts\Support\Arrayable;
/**
* Class MenuComposite
* @package Exdeliver\Causeway\Domain\Entities\Menu
@renalpha
renalpha / phpstorm-cs-fixer.md
Last active May 8, 2019 13:01 — forked from nienkedekker/phpstorm-cs-fixer.md
Set up PHP-CS-Fixer in PHPStorm

Use PHP-CS-Fixer in PHPStorm

  • Install PHP-CS-Fixer on your local machine according to these instructions: https://github.com/FriendsOfPHP/PHP-CS-Fixer
  • Open PHPStorm, Preferences > Tools > External Tools and enter these values: img
  • Program, edit to match your path where PHP-CS-Fixer lives: /.composer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer
  • Parameters: --rules=@PSR2 --verbose fix $FilePath$. Note that previous verions of PHP-CS-Fixer used --levels instead of --rules.
  • Working directory: $ProjectFileDir$

Click OK and Apply. Now we'll set up a shortcut.

  • Go to Preferences > Keymap and search for "PHP Fixer" (or whatever name you gave it). Add whatever shortcut you like, I'm using ctrl + cmd + ]:
@renalpha
renalpha / install-rabbitmq.sh
Last active May 8, 2019 17:23 — forked from yetanotherchris/install-rabbitmq.sh
RabbitMQ on Docker with admin UI
# AWS specific install of Docker
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
# exit the SSH session, login again
# Docker
(docker rm -v some-rabbit)
@renalpha
renalpha / Team.php
Last active April 9, 2019 09:02
Dedicated builder object
<?php
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
class Team extends Model
{
public function newEloquentBuilder(Builder $builder)
{
return new TeamBuilder($builder);
@renalpha
renalpha / LoginComponent.vue
Last active February 26, 2019 14:52
Login vue
<template>
<form method="POST" :action="login_route" id="login-form" v-on:submit="loginPost">
<input type="hidden" name="_token" :value=csrf_token />
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">E-mail address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" v-model="loginDetails.email" autofocus>
<span v-if="formErrors.email" class="help-block text-danger">{{ formErrors.email[0] }}</span>
</div>
@renalpha
renalpha / currency_convert_int.php
Created February 7, 2019 13:20
Transform formatted price with possible currency to integer
<?php
$value = (int)preg_replace("/([^0-9\\.])/i", '', $value);
@renalpha
renalpha / test.php
Last active December 6, 2018 12:11
Larvel Passport test get access token
class PassportTest extends TestCase
{
/** @test */
public function unauthenticated_cannot_access_api_endpoint()
{
$response = $this->get('api/queue/list');
$response->assertRedirect('/login');
}
/** @test */
@renalpha
renalpha / AbstractRepository.php
Created November 23, 2018 09:52
Domain Driven Design Laravel
<?php
namespace Infrastructure\Repositories;
use Domain\Common\Entity;
use Domain\Contracts\Repository\AbstractRepositoryInterface;
use Illuminate\Database\Eloquent\Model;
/**
* Class AbstractRepository
@renalpha
renalpha / Mailable.php
Last active November 23, 2018 08:21
Easy mailables by using notifications
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
/**
* Class Mailable
@renalpha
renalpha / AbstractDomainService.php
Last active August 27, 2018 14:57
Interface binding
<?php
namespace Domain\Abstractions;
/**
* Class AbstractDomainService
*
* @package Domain\Abstractions
*/
abstract class AbstractDomainService