Skip to content

Instantly share code, notes, and snippets.

@gilbitron
gilbitron / CaddyController.php
Created June 16, 2021 10:55
Enabling HTTPS (SSL) for Laravel Sail using Caddy
<?php
# app/Http/Controllers/CaddyController.php
namespace App\Http\Controllers;
use App\Store;
use Illuminate\Http\Request;
class CaddyController extends Controller
{
@akatche
akatche / createdb.sql
Last active October 7, 2022 13:08
Run Laravel parallel tests using Laravel Sail
#
# Create this file in the following folder docker/mysql/docker-entrypoint-initdb.d
#
CREATE DATABASE IF NOT EXISTS `test_1` COLLATE 'utf8_general_ci' ;
GRANT ALL ON `test_1`.* TO 'root'@'%' ;
CREATE DATABASE IF NOT EXISTS `test_2` COLLATE 'utf8_general_ci' ;
GRANT ALL ON `test_2`.* TO 'root'@'%' ;
@garethredfern
garethredfern / .env.github
Last active April 30, 2024 10:52
Github workflow for Laravel CI testing using a MYSQL database.
APP_ENV=ci
APP_KEY=
SESSION_DRIVER=array
CACHE_DRIVER=array
QUEUE_DRIVER=sync
MAIL_DRIVER=log
@ciamarro
ciamarro / livewire-directive.md
Created March 18, 2020 13:15
@livewire directive for phpstorm
  1. File > Settings > Languages & Frameworks > PHP > Blade
  2. Uncheck use default settings
  3. Directives > +
  4. Name livewire
  5. Prefix <?php '', [
  6. Suffix ])?&gt;
@danreb
danreb / dgscanner.sh
Last active July 9, 2018 00:45
Helper shell scripts or command to scan for injected code - DrupalGeddon 2 - 3
#!/bin/bash
# Run this inside your cPanel account or just in public_html drupal web root
# Find the ico malware
find . -type f -name "favicon_*.ico"
find . -type f -name ".*.ico"
# Delete the malware, I did not delete favicon_*.ico as you need to double check it manually
find . -type f -name ".*.ico" -exec rm -f {} \;
@holmberd
holmberd / php-pools.md
Last active July 23, 2024 15:06
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
@addyosmani
addyosmani / workbox.md
Last active January 20, 2024 16:14
Workbox recipes

Workbox runtime caching recipes

Your Service Worker script will need to import in Workbox and initialize it before calling any of the routes documented in this write-up, similar to the below:

importScripts('workbox-sw.prod.v1.3.0.js');
const workbox = new WorkboxSW();

// Placeholder array populated automatically by workboxBuild.injectManifest()
@james2doyle
james2doyle / test-was-called.php
Last active February 21, 2022 21:52
Testing that an event listener was called in Laravel without additional frameworks
<?php
// overall test answer
$was_called = false;
$this->app->resolving(function ($object, $app) use (&$was_called) {
if ($object instanceof MyEventListener) {
// the object was resolved at one point
$was_called = true;
}