Skip to content

Instantly share code, notes, and snippets.

View tarsislima's full-sized avatar

Tarsis Lima tarsislima

  • Salvador-BA, Brazil
View GitHub Profile
@onamfc
onamfc / AccessToken.php
Last active September 19, 2024 10:18
Add Custom Claims to Passport 8 / Laravel 6
<?php
namespace App\Passport;
use App\User;
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Key;
use League\OAuth2\Server\CryptKey;
use Lcobucci\JWT\Signer\Rsa\Sha256;
use Laravel\Passport\Bridge\AccessToken as BaseToken;
Simple contract or interface, call as you wish:
interface UnitOfWork
{
public function begin();
public function commit();
public function rollback();
}
@mariovalney
mariovalney / pre-commit
Last active January 31, 2025 19:28
Pre-commit hook to check code with PHPCS, fix with PHPCBF and check mess with PHPMD
#!/bin/sh
#########################
# #
# Initializing #
# #
#########################
##
# You should add all tools as composer dependencies or change this path
@ygrenzinger
ygrenzinger / CleanArchitecture.md
Last active April 28, 2025 15:23
Summary of Clean Architecture by Robert C. Martin

Summary of book "Clean Architecture" by Robert C. Martin

Uncle Bob, the well known author of Clean Code, is coming back to us with a new book called Clean Architecture which wants to take a larger view on how to create software.

Even if Clean Code is one of the major book around OOP and code design (mainly by presenting the SOLID principles), I was not totally impressed by the book.

Clean Architecture leaves me with the same feeling, even if it's pushing the development world to do better, has some good stories and present robust principles to build software.

The book is build around 34 chapters organised in chapters.

@g0ld3lux
g0ld3lux / App.Http.Controllers.HomeController.php
Last active December 13, 2019 14:36
Setting up vue material + laravel 5.4
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
@vinicius73
vinicius73 / CustomValidatorsServiceProvider.php
Last active May 5, 2016 20:54
Helper para datas Laravel
<?php
namespace App\Support\Validators;
use Illuminate\Support\ServiceProvider;
use Illuminate\Validation\Factory as ValidatorFactory;
class CustomValidatorsServiceProvider extends ServiceProvider
{
public function boot()
@laracasts
laracasts / StatusRepository.php
Last active May 19, 2018 15:11
Integration Testing Repositories That Use Eloquent (with Codeception)
<?php namespace Larabook\Statuses;
use Larabook\Users\User;
class StatusRepository {
/**
* Get all statuses associated with a user.
*
* @param User $user
@alganet
alganet / tipagem_primitiva.md
Last active August 12, 2019 22:48
PHP Prático: Tipagem Primitiva

PHP Prático: Tipagem Primitiva

A primeira coisa a saber sobre a tipagem do PHP é que ela não é parecida com Java, JavaScript, Python, Ruby, C, C++, C# ou qualquer linguagem que tenha uma tipagem baseada em alguma dessas citadas. A tipagem do PHP é incomparável, e assim como tudo que não pode ser comparado é difícil de ser explicada.

De qualquer forma, a tipagem do PHP é extremamente simples se você apenas confiar na sua intuição. A primeira coisa que você tem que saber sobre a tipagem do PHP é que ela faz malabarismos. É exatamente essa a palavra: malabarismo. E o PHP é um ótimo malabarista, exceto por alguns poucos deslizes fáceis de decorar. O type juggling, traduzido para "malabarismo com tipos" é a habilidade que o PHP tem de tomar decisões intuitivas sobre conversões de tipos. Em termos grosseiros, o PHP decide toda e qualquer tipagem de variáveis em tempo de execução, não compilação (pros pedante aí que tão lendo).

Note bem: tipagem de variáveis. O PHP é multi-paradigma e, ao m