Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
<?php | |
use Symfony\Component\Translation\TranslatorInterface; | |
function format(\DateTime $date, TranslatorInterface $translator) | |
{ | |
$diff = date_create()->diff($date); | |
$seconds = $diff->days * 86400 + $diff->h * 3600 + $diff->i * 60 + $diff->s; | |
$format = $translator->transChoice('reldate', $seconds); |
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
#!/usr/bin/env php | |
<?php | |
/** | |
* .git/hooks/pre-commit | |
* | |
* This pre-commit hooks will check for PHP errors (lint), and make sure the | |
* code is PSR-2 compliant. | |
* | |
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer) | |
*/ |
set :dev_only_files, [web_path + "/app_dev.php", web_path + "/check.php", web_path + "/config.php"] | |
set :production, true | |
after 'symfony:cache:warmup', 'pff:productify' | |
namespace :pff do | |
desc "Remove app_dev.php, check.php and config.php from production deployment" | |
task :productify, :except => { :production => false } do | |
if dev_only_files | |
pretty_print "--> Removing app_dev.php, config.php, and check.php from web" |
\Doctrine\DBAL\Types\Type::addType('uuid', 'BuboBox\Doctrine2\DBAL\Types\UuidType'); |
#!/bin/bash | |
# parses a tap log file from phpunit to find failed tests | |
# | |
# This assumes you setup a phpunit.xml (or .dist.xml) so simply add something like the following under <phpunit> | |
# <logging> | |
# <log type="tap" target="/tmp/.projectname-phpunit-test-log.tap" /> | |
# </logging> | |
# | |
# tap is used instead of json and xml because these log files get big |
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
// see: https://github.com/chadoe/docker-cleanup-volumes
$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
{% extends 'form_div_layout.html.twig' %} | |
{% block form_row -%} | |
<div class="row{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}"> | |
<div class="input-field col s12"> | |
{{- form_widget(form) -}} | |
{{- form_label(form) -}} | |
{{- form_errors(form) -}} | |
</div> | |
</div> |
{% extends 'form_div_layout.html.twig' %} | |
{% block form_row -%} | |
<div class="row{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}"> | |
<div class="input-field col s12"> | |
{{- form_widget(form) -}} | |
{{- form_label(form) -}} | |
{{- form_errors(form) -}} | |
</div> | |
</div> |