Skip to content

Instantly share code, notes, and snippets.

View ahoulgrave's full-sized avatar

Agustín Houlgrave ahoulgrave

  • New Relic
  • Barcelona, España
View GitHub Profile
# docker-compose.yml
version: '3'
services:
web:
container_name: my_php_app
build: .
ports:
- "80:80"
volumes:
- cache:/data/cache
#!/bin/sh
# build/composer.sh
EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE="$(php -r "echo hash_file('SHA384', 'composer-setup.php');")"
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
;build/supervisor.conf
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
nodaemon=true
[program:nginx]
command=/usr/sbin/nginx -g 'daemon off;'
autostart=true
# build/site.conf
server {
listen 7102;
server_name ~.;
root /var/www/html/public;
location / {
try_files $uri /index.php$is_args$args;
}
# Dockerfile
FROM phusion/baseimage
ENV DEBIAN_FRONTEND noninteractive
# Install PHP
RUN add-apt-repository -y ppa:ondrej/php && apt-get update
RUN apt-get install -y \
# Only install the php extensions you need.
php7.1-fpm \
php7.1-mcrypt \
@ahoulgrave
ahoulgrave / smart_pagination.php
Last active March 24, 2018 21:10
PHP smart pagination
<?php
/**
* @param int $page
* @param int $total
* @param int $range
*
* @return array
*/
function getPages(int $page, int $total, int $range): array
{
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Class MyCommand
*
<?php
class User
{
/**
* @var string
*/
private $name;
@ahoulgrave
ahoulgrave / appendParam.php
Last active March 10, 2016 00:33
Function to append a parameter to an url querystring
/**
* @param $value
* @param string $param
* @return string
*/
public function appendParam($param, $value)
{
$url = $this->request->getUri();
$queryString = parse_url($url, PHP_URL_QUERY);
$params = [];
{% for label, flashes in app.session.flashbag.all %}
{% for flash in flashes %}
<div class="alert alert-{{ label }}">
{{ flash }}
</div>
{% endfor %}
{% endfor %}