Skip to content

Instantly share code, notes, and snippets.

@mnapoli
mnapoli / example.php
Created October 26, 2018 18:12
Async MySQL
<?php
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
use ProxyManager\Proxy\ProxyInterface;
require_once __DIR__ . '/vendor/autoload.php';
$mysql = mysqli_connect('localhost', 'root', '', 'example');
$factory = new LazyLoadingValueHolderFactory();
<?php
// See https://wiki.php.net/rfc/named_params
return new TwigConfig(
paths => [
'%kernel.project_dir%/vendor/acme/foo-bar/templates' => 'foo_bar',
],
autoescape => true,
strictVariables => false,
@mnapoli
mnapoli / README.md
Last active August 31, 2018 12:04
Docker + xdebug

php.ini:

xdebug.remote_enable=on
xdebug.remote_autostart=on
xdebug.remote_port=9000
xdebug.remote_host=host.docker.internal
xdebug.remote_connect_back=0
@mnapoli
mnapoli / .zshrc
Last active August 24, 2018 16:52
Docker Compose shortcut
# Docker-Compose shortcut:
# - before: docker-compose exec app <command>
# - after: d <command>
# The alias will auto-start the service if it is stopped.
# Requirements:
# - jq: https://stedolan.github.io/jq/
# - yq: https://github.com/kislyuk/yq
# Add this to your `~/.zshrc` at the end because `d` is an existing (unrelated) alias we want to override

Usage:

php script.php test.plt

Sample output:

G01 X-7626 Y-392 Z0
#!/bin/bash
set -e
cd /tmp
echo "Installing PHP"
#mkdir /tmp/php
#curl -sSL https://s3-eu-west-1.amazonaws.com/mnapoli/test-aws/php.tar.gz | tar -xz -C /tmp/php
@mnapoli
mnapoli / iterable.md
Last active July 3, 2016 20:06
Iterable
can be used with foreach(… array_*(…) functions yield from … array type-hint Traversable type-hint can be implemented
array
Traversable
iterable
@mnapoli
mnapoli / .phpstorm.meta.php
Created July 1, 2016 11:36
PHPUnit autocompletion with PhpStorm's latest EAP
<?php
namespace PHPSTORM_META {
$STATIC_METHOD_TYPES = [
\PHPUnit_Framework_TestCase::createMock('') => [
"" == "@|PHPUnit_Framework_MockObject_MockObject",
],
\PHPUnit_Framework_TestCase::getMock('') => [
"" == "@|PHPUnit_Framework_MockObject_MockObject",
],
@mnapoli
mnapoli / PHP-DI 6.md
Last active March 15, 2016 22:11
PHP-DI 6

PHP-DI 6 ideas

Main changes:

Rename a few helpers to actions:

  • factory() -> call()
  • object() -> create()

This is hopefully clearer on what will actually be done.

<?php
namespace TwigModule;
use Interop\Container\ContainerInterface;
use Interop\Container\ServiceProvider\ServiceProvider;
use Puli\Repository\Api\ResourceRepository;
use Puli\TwigExtension\PuliExtension;
use Puli\TwigExtension\PuliTemplateLoader;
use Puli\UrlGenerator\Api\UrlGenerator;