Skip to content

Instantly share code, notes, and snippets.

@vanthao03596
vanthao03596 / Laravel-Container.md
Created November 6, 2020 08:33
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

@vanthao03596
vanthao03596 / InviteCode.php
Created March 25, 2021 08:10 — forked from guanguans/InviteCode.php
InviteCode.php
<?php
/**
* Class InviteCode
* 邀请码生成类
*
* ```
* $inviteCode = new InviteCode('123456789');
* var_dump($inviteCode->enCode(1)); // string(8) "00000002"
* var_dump($inviteCode->deCode("00000002")); // int(1)
@vanthao03596
vanthao03596 / Middleware-CSP.php
Created May 3, 2023 04:30 — forked from valorin/.env.example
CSP Middleware - the simple CSP middleware I use across all of my projects.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Vite;
use Illuminate\Support\Str;
/**
* Simple Content Security Policy middleware.