Skip to content

Instantly share code, notes, and snippets.

View alexander-schranz's full-sized avatar

Alexander Schranz alexander-schranz

View GitHub Profile
@alexander-schranz
alexander-schranz / PhpCrFixerCommand.php
Created October 19, 2023 14:20
A command to check if default workspace is not longer in sync with live workspace in Sulu CMS
<?php
declare(strict_types=1);
namespace App\Command;
use PHPCR\NodeInterface;
use PHPCR\Query\RowInterface;
use PHPCR\SessionInterface;
use Sulu\Component\Webspace\Manager\WebspaceManagerInterface;
@alexander-schranz
alexander-schranz / PHP-Cache-Files-and-Directories.md
Last active October 25, 2023 13:50
PHP Tools default cache files and directories

PHP Tool Cache Files and Directories

Collecting here which PHP Tools use caches here and for which usecase.

The widely used sys_get_temp_dir() method represents TMPDIR environment variable if not specially sys_temp_dir is defined in the php.ini file.

PHPStan

Can avoid reanalyzing unrelated files:

@alexander-schranz
alexander-schranz / DebugMemoryUsageTestListener.php
Last active July 17, 2023 22:42
Debug Memory Usage of PHPUnit TestCase
<?php
declare(strict_types=1);
namespace App\Tests;
use PHPUnit\Framework\TestListener;
use PHPUnit\Framework\TestListenerDefaultImplementation;
use PHPUnit\Framework\TestSuite;
@alexander-schranz
alexander-schranz / CleanUpPropertiesTestListener.php
Last active July 17, 2023 23:09
Prototype of a listener cleaning up all properties of a PHPUnit class. WARNING: This didn't decrease any memory usage for me!
<?php
declare(strict_types=1);
namespace App\Tests;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestListener;
use PHPUnit\Framework\TestListenerDefaultImplementation;
use PHPUnit\Framework\TestSuite;
<?php
declare(strict_types=1);
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\Process\ExecutableFinder;
require \dirname(__DIR__) . '/vendor/autoload.php';
(new Dotenv())->bootEnv(\dirname(__DIR__) . '/.env');
@alexander-schranz
alexander-schranz / base.html.twig
Last active February 14, 2023 13:01
Lazy and Passive Slick
<!DOCTYPE html>
<html lang="{{ app.request.locale|split('_')[0] }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
{#-
Various Tools should be used to validate HTML, Accessibility, Structured Data and speed of the site:
- HTML Validation:
@alexander-schranz
alexander-schranz / deploy.php
Last active January 26, 2023 17:36
Deployer deploy.php without Git Repository
<?php
namespace Deployer;
use Deployer\Task\GroupTask;
require 'recipe/sulu.php';
require 'contrib/rsync.php';
host('example.org')
@alexander-schranz
alexander-schranz / detect.sh
Last active January 5, 2023 17:50
Detect Symfony Components used inside your project to migrate symfony/symfony to specific components
# copy this into your shell/terminal:
php -r '
require_once("vendor/autoload.php");
use Symfony\\Component\\Finder\\Finder;
$symfonyComponents = [];
$useFinder = new Finder();
@alexander-schranz
alexander-schranz / composer-info-date.php
Created December 16, 2022 15:55
Get Composer Vendor Package Version date
<?php
// requires `rm -rf vendor && composer install --prefer-source` as it works via git tag
$dir = new DirectoryIterator(__DIR__ . "/vendor");
$list = [];
$biggestLength = 0;
foreach ($dir as $fileinfo) {
if (in_array($fileinfo->getFilename(), [".", ".."])) {
@alexander-schranz
alexander-schranz / example1.scss
Last active October 11, 2022 15:07
Example Font Size Settings
$font-family-headline: 'Lyon';
$font-family-base: 'Source Sans Pro';
$font-settings: (
mobile-headline-l: (
font-family: $font-family-headline,
font-size: 34px,
line-height: 38px,
font-weight: $font-weight-bold,
),