Skip to content

Instantly share code, notes, and snippets.

View DarkGhostHunter's full-sized avatar
👨‍💻
Hands full

Italo DarkGhostHunter

👨‍💻
Hands full
View GitHub Profile
@DarkGhostHunter
DarkGhostHunter / AuthenticatedComposer.php
Created January 11, 2020 20:53
Adds the authenticated user globally to all views
<?php
namespace App\Http\View\Composers;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\View\View;
class AuthenticatedComposer
{
/**
@DarkGhostHunter
DarkGhostHunter / ManagerServiceProvider.php
Created January 10, 2020 23:56
Registration of a Single Manager using a Service Provider
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Managers\Transport\TransportManager;
use App\Managers\Transport\TransportContract;
class TransportServiceProvider extends ServiceProvider
{
<?php
namespace App;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
trait HasToken
{
@DarkGhostHunter
DarkGhostHunter / ExampleController.php
Last active November 11, 2022 05:26
A controller using the CachesResponse trait
<?php
namespace App\Controllers;
use App\Podcast;
use App\Http\Helpers\CachesResponses;
use Illuminate\Http\Request;
use Podcast\PodcastAnalytics\PodcastAnalytics;
class PodcastController extends Controller
@DarkGhostHunter
DarkGhostHunter / preload.php
Last active July 18, 2023 18:14
Preloader script
<?php
/**
* This file is generated automatically by Preloader.
*
* This script uses Composer Autoload file and `require_once` to preload the files in this
* list. Add this file to your `php.ini` in `opcache.preload` to preload this list into
* PHP at startup. Additionally, this file also includes information about Opcache.
*
*
* Add (or update) this line in `php.ini`:
@DarkGhostHunter
DarkGhostHunter / preload.json
Last active November 28, 2019 04:14
Preload JSON for composer.json
{
"pre-compile": [
"my-script.php",
"my-other-script.php"
],
"extensions": [
"php"
],
"files": [
"app/*",
@DarkGhostHunter
DarkGhostHunter / preload-compiled.php
Last active November 27, 2019 18:51
Preload final file
<?php
/**
* Preloading @generated by Composer
*/
// Autoload the classes so those can be preloaded using `require_once`.
require_once __DIR__.'/../autoload.php';
// File list
$files = [
@DarkGhostHunter
DarkGhostHunter / preload.php
Created November 27, 2019 05:21
A sample preload file
<?php
// Get the list of files of the main directory and remove the dots
$files = array_diff(scandir(__DIR__ . '/src/'), array('..', '.'));
// Add the helpers file
$files[] = 'helpers/helpers.php';
return $files;
@DarkGhostHunter
DarkGhostHunter / composer.json
Last active November 27, 2019 05:40
Composer JSON with preloadin
{
"name": "application/project",
"description": "This is my root project.",
"require": {
"php": "^7.2",
"ext-json": "*",
"symfony/http-client": "5.*",
"symfony/console": "5.*"
},
"autoload": {
@DarkGhostHunter
DarkGhostHunter / Manager.php
Created November 17, 2019 21:04
Latest 6.x version of the Laravel Manager Class.
<?php
namespace Illuminate\Support;
use Closure;
use Illuminate\Contracts\Container\Container;
use InvalidArgumentException;
abstract class Manager
{