Skip to content

Instantly share code, notes, and snippets.

<?php
namespace Vehikl\Feature\Tests;
use PHPUnit\Framework\TestCase;
class FeatureToggleTest extends TestCase
{
public function test_it_executes_the_on_method_when_the_feature_is_on()
{
@timacdonald
timacdonald / ContactIndexResponse.php
Last active February 9, 2023 21:48
Easily respond to content types and url extensions
<?php
namespace App\Http\Responses;
use App\Models\ContactType;
use App\Factories\CsvFactory;
class ContactIndexResponse extends Response
{
public function __construct($contacts)
@imbrish
imbrish / MacroServiceProvider.php
Created January 30, 2018 14:46
Locale-aware & multi-key sorting of arrays
<?php
namespace App\Providers;
use Illuminate\Support\Collection;
use Illuminate\Support\ServiceProvider;
class MacroServiceProvider extends ServiceProvider
{
/**
@Alymosul
Alymosul / README.md
Last active February 22, 2024 14:45
[Laravel] Seeding data in testing as part of the application build.

SeedDatabase trait along with SeedDatabaseState class gives your Laravel project the ability to seed the testing database once before running the full suite tests, which improves the speed of the tests than seeding the testing database before each test.

Also, it has the option to run custom seeders instead of the seeders that are called in the run() method of the DatabaseSeeder class you can achieve that as follows

...in the Testcase.php

public function setUp()

{

@zabaala
zabaala / BindDatabaseServiceProvider.php
Last active March 2, 2021 07:50
php artisan db:log <start> <stop>
<?php
namespace App\Commands\Database;
use Illuminate\Support\ServiceProvider;
class BindDatabaseServiceProvider extends ServiceProvider
{
public function boot()
{
@poul-kg
poul-kg / valet.conf
Last active April 30, 2024 14:09
CORS Rules for Laravel Valet Nginx
# To enable CORS you should add lines with CORS rules below to your valet.conf file
# Find the file /usr/local/etc/nginx/valet/valet.conf - this is Valet conf for Nginx
# of try to execute `locate valet.conf` and find the `valet.coinf` in `nginx` subdirectory
# after you edit your valet.conf do not forget to execute `valet restart`
server {
listen 80 default_server;
root /;
charset utf-8;
client_max_body_size 128M;
# Usage:
# l project-name -a
#
# Available options:
# -a Authentication scaffolding with tests
# -g Add Github remote
# -d Create a fresh MySQL database
# Laravel Zonda
function l {
@reinink
reinink / in-memory-sqlite-database.php
Created September 26, 2017 00:13
Give users completely safe sandboxed raw SQL reporting abilities
<?php
// Create in-memory SQLite database
$sqlite = new PDO('sqlite::memory:');
// Generate schema (for whatever tables you want)
$sqlite->prepare('CREATE TABLE users(id, family_id, first_name, last_name, email)')->execute();
$sqlite->prepare('CREATE TABLE families(id, name, phone, address)')->execute();
// Insert pre-defined data
@paulredmond
paulredmond / ValidateMailgunWebhook.php
Created April 24, 2017 21:55
Laravel Middleware to Validate a signed Mailgun webhook
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Response;
/**
* Validate Mailgun Webhooks
* @see https://documentation.mailgun.com/user_manual.html#securing-webhooks
@vicgonvt
vicgonvt / Xdebug.md
Last active April 5, 2019 18:29
Instructions for Installing Xdebug in a Mac with Laravel, Valet and Sublime Text

NOTE: This assumes that you have Valet, Homebrew, Sublime Text and PHP properly installed and functioning and will only focus on the setup and installation and setup of Xdebug. There are other tutorials that go into great depth explaining how to get those tools installed on your mac.

Let's get started right away!

Installing Xdebug

You need to know which version of PHP you are running in your machine. To do so, from the terminal run the command php -v and this will display something like this

PHP 7.0.14 (cli) (built: Dec  8 2016 23:34:17) ( NTS )