Skip to content

Instantly share code, notes, and snippets.

@lennardv2
lennardv2 / 1. Building PHP-MAMP on Apple Silicon M1.md
Last active October 3, 2024 20:29
Native PHP development / MAMP stack on Apple silicon M1

Building the MAMP stack (php, apache & mysql) on Apple Silicon ARM (native)

Update! This tutorial is outdated. Nowadays brew installes m1 binaries just fine. Also use valet: https://laravel.com/docs/9.x/valet. It's 10x easier.

In this tutorial, we'll build the the nescessary packages for ARM via homebrew. After that we'll configure apache2 for using virtual hosts. The native php is ofcourse way faster, see the results of this benchmark below.

TEST NAME SECONDS OP/SEC
@lennardv2
lennardv2 / readme.md
Last active January 14, 2021 16:16
Search macro for laravel/eloquent

Use like:

User::query()->search(["first_name", "last_name", "role.name"], "some query")
@lennardv2
lennardv2 / 0 - Readme.md
Last active July 29, 2023 00:02
Make livewire components more secure by default by using these traits

Livewire Security

Make livewire components more secure by default by using these traits

This trait is used to protect public livewire properties from being changed by the user by default in frontend via Livewire JS calls. See: https://www.reddit.com/r/laravel/comments/q0qrri/livewire_extremely_insecure/

If you want to 'expose' methods and properties you must use the $callable and $mutable properties to do so. By default every property defined in $rules or rules() is considered mutable.

This trait will throw an exception if mutable and callable properties are non-existant on your component;

@lennardv2
lennardv2 / archivedl.php
Created June 1, 2023 13:39 — forked from divinity76/archivedl.php
Fork of archivedl.php to make it work with php8.2
#!/usr/bin/php
<?php
declare(strict_types = 1);
// require_once ('hhb_.inc.php');
hhb_init ();
if ($argc !== 3) {
fprintf ( STDERR, "usage: %s timestamp url\n", $argv [0] );
fprintf ( STDERR, "example: %s 20091012061648 http://www.p4w.se\n", $argv [0] );
die ( 1 );
}