Skip to content

Instantly share code, notes, and snippets.

View maglnet's full-sized avatar
😀

Matthias Glaub maglnet

😀
View GitHub Profile
@yaredc
yaredc / no-warnings-and-notices.php
Last active September 9, 2019 21:22
Fix all PHP notices and warnings with this one simple trick!
<?php
declare(strict_types=1);
/*
* Convert all notices and warnings to errors.
* There is no point in warnings and notices.
*/
set_error_handler(static function ($errno, $errstr, $errfile, $errline): bool {
switch ($errno) {
@hoandang
hoandang / php-docker-ext
Created May 20, 2017 01:12
Complete list of php docker ext
RUN apt update
RUN apt upgrade -y
RUN apt install -y apt-utils
RUN a2enmod rewrite
RUN apt install -y libmcrypt-dev
RUN docker-php-ext-install mcrypt
RUN apt install -y libicu-dev
RUN docker-php-ext-install -j$(nproc) intl
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
<?php
namespace Module\Entity;
/**
* @ORM\Entity
*/
class EntityA
{
/**
* @ORM\ManyToOne(targetEntity="Module\Entity\EntityBInterface", fetch="LAZY")
@mrkrstphr
mrkrstphr / README.md
Last active February 5, 2019 13:17
Deploying Sculpin Sites to GitHub Pages

Deploying Sculpin Sites to GitHub Pages

I wanted to be able to use Sculpin to generate GitHub pages. Here's what I did...

  1. Created a super awesome Sculpin site from the Sculpin Blog Skeleton

  2. Make sure everything is under version control in my master branch (except things that shouldn't be. see the .gitignore)

  3. Updated publish.sh:

#!/bin/bash

<?php
class MyInputFilter extends InputFilter
{
public function __construct()
{
$this->add(['name' => 'example', 'required' => false]);
$this->add(['name' => 'foo', 'required' => false]);
$this->add(['name' => 'bar', 'required' => false]);
}
@jk
jk / UnitTestPrivateMethods.php
Last active August 29, 2015 13:58
Helper method to test private and protected methods with PHPUnit (it's not bound to PHPUnit what so ever)
<?php
class PHPUnitHelper {
/**
* Helps testing private and protected methods on SAC objects
* @param object $class_instance class instance object
* @param $method Method name
* @return mixed method return value
*/
public static function invokePrivateMethod($class_instance, $method_name) {
$method = new ReflectionMethod(get_class($class_instance), $method_name);
mkdir scrutinizer && cd scrutinizer
# Install tools
# - Scrutinizer and composer
wget http://scrutinizer-ci.com/scrutinizer.phar
curl -sS https://getcomposer.org/installer | php
# - All needed CI tools
php composer.phar require h4cc/phpqatools:~1.2
cp -p composer.phar vendor/bin/composer
@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active November 24, 2024 21:24
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

/**
* Tries to injects the toolbar into the view. The toolbar is only injected in well
* formed HTML by replacing the closing body tag, leaving ESI untouched.
*
* @param ProfilerEvent $event
*/
protected function injectToolbar(ProfilerEvent $event)
{
$entries = $this->renderEntries($event);
$request = $event->getApplication()->getRequest();