Skip to content

Instantly share code, notes, and snippets.

View Tjitse-E's full-sized avatar

Tjitse Tjitse-E

View GitHub Profile
@Tjitse-E
Tjitse-E / phpmd.xml
Created August 15, 2024 13:43
Vendic's customized Magento phpmd config
<?xml version="1.0"?>
<ruleset name="PHPMD"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>PHPMD</description>
<!-- Exclude files -->
<exclude-pattern>phpserver/*</exclude-pattern>
@Tjitse-E
Tjitse-E / rector.php
Created January 29, 2024 13:50
Add missing dynamic properties using RectorPHP
<?php
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(CompleteDynamicPropertiesRector::class);
// Define directories to check
$directories = [
@Tjitse-E
Tjitse-E / composer_json_add.sh
Created September 28, 2023 05:58
Add section to composer.json
cat composer.json |
jq 'if .extra then . else . + {"extra": {}} end' |
jq --indent 4 '.extra["magento-deploy-ignore"] = {
"*": [
"/CHANGELOG.md",
"/.gitignore",
"/.htaccess.sample",
"/.php-cs-fixer.dist.php",
"/.user.ini",
"/COPYING.txt",
@Tjitse-E
Tjitse-E / phpunit_config_to_v9.php
Created January 3, 2023 13:46
Update PHPUnit config from 6.2 to 9.5
<?php
$doc1 = new DOMDocument();
$doc1->load('dev/tests/integration/phpunit.xml');
$xmlToAdd = new DOMDocument();
$xmlToAdd->loadXML('<coverage>
<exclude>
<directory suffix=".php">../../../app/code/Magento</directory>
<directory>../../../app/code/*/*/Test</directory>
commit cb985f7401925639e25f55b93cdb44613fcfa1a9
Author: Tjitse Efdé <[email protected]>
Date: Tue Nov 8 14:30:19 2022 +0100
M245 fix setup:static-content:deploy timeout (https://github.com/magento/magento2/commit/12a9eacaf57baf1dbd71b22cbd9ada32f3ffa479)
diff --git a/Collector/Collector.php b/Collector/Collector.php
index b09001a..441d165 100644
--- a/Collector/Collector.php
+++ b/Collector/Collector.php
@Tjitse-E
Tjitse-E / CustomMagento2ValetDriver.php
Created November 9, 2022 18:24
Magento 2 driver for Laravel Valet
<?php
// Copied from https://github.com/weprovide/valet-plus/blob/2.x/cli/drivers/Magento2ValetDriver.php
class CustomMagento2ValetDriver extends Magento2ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
@Tjitse-E
Tjitse-E / apply_244-p2_security_patch.sh
Last active October 16, 2022 19:46
Apply Magento 2.4.4-p2 security patch
#!/usr/bin/env bash
# exit when any command fails
set -e
# keep track of the last executed command
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# echo an error message before exiting
trap 'echo "\"${last_command}\" command filed with exit code $?."' EXIT
@Tjitse-E
Tjitse-E / changelog_fixer.sh
Last active September 27, 2022 11:29
Fix common errors in CHANGELOG.md
#!/bin/zsh
sed=$(which sed)
if [ "$(uname -s)" = "Darwin" ]
then
sed=$(which gsed)
fi
# Fix incorrect date format. For example 1-01-2021
$sed -i -E "s/^([0-9])-([0-9]{2})-([0-9]{4})/0\1-\2-\3/" CHANGELOG.md
@Tjitse-E
Tjitse-E / valet-install.md
Created April 14, 2022 09:20
Valet+ install on M1 Mac's.

Install Valet+

Install brew

First we need to install Brew, the dependency for the Mac:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install PHP

MacOS Monterney comes without PHP. Valet+ uses a special version of PHP that you can install like this:

@Tjitse-E
Tjitse-E / magento_generate_store_mapping.sh
Last active June 15, 2021 12:51
Generate a Magento 2 store mapping
#!/usr/bin/env bash
# Generates the Magento multistore config based on the base url list that's provided by n98-magerun2
# You can place the output in pub/index.php
IFS='
'
magerun2=$(which n98-magerun2)
[ -z "$magerun2" ] && echo "Cannot find magerun2, exiting." && exit 1
echo "switch (\$_SERVER['HTTP_HOST']) {"