Skip to content

Instantly share code, notes, and snippets.

View COil's full-sized avatar
🎯
Focusing

Loïc Vernet COil

🎯
Focusing
View GitHub Profile
@COil
COil / error429.html.twig
Created November 4, 2018 09:53
Example of Twig template for the 429 error code (HTTP_TOO_MANY_REQUESTS)
{# templates/bundles/TwigBundle/Exception/error429.html.twig #}
{% extends 'layout.html.twig' %}
{% block meta_title %}Error {{ status_code }}, too many login attempts{% endblock meta_title %}
{% block body %}
<h1>Security warning</h1>
<h2>Too many login attempts</h2>
@COil
COil / AdminController.php
Last active January 13, 2018 19:30
phpinfo() action for the easy admin bundle
<?php
// src/AppBundle/Controller/Admin/AdminController.php
namespace AppBundle\Controller\Admin;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AdminController as BaseAdminController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
easy_admin:
design:
menu:
label: System
icon: 'server'
children:
- { label: 'PHP Info', route: easyadmin_phpinfo, icon: 'info' }
@COil
COil / services.yml
Created October 16, 2017 14:12
Redis full DNS with database and port example + SNC bundle basic config
# @see https://github.com/snc/SncRedisBundle/blob/master/Resources/doc/index.md
parameters:
app_version: 6.0.0
# Redis
snc_redis.dsn: redis://%redis_node_1%:%redis_port%/%redis_database%
# https://github.com/snc/SncRedisBundle/blob/master/Resources/doc/index.md
snc_redis:
clients:
@COil
COil / AppController.txt
Created February 28, 2017 13:49
AppController.php (output dump)
AppController.php on line 68:
array:33 [▼
"get('foo')" => "bar"
"hasPreviousSession" => true
"hasSession" => true
"getClientIps" => array:1 [▼
0 => "127.0.0.1"
]
"getClientIp" => "127.0.0.1"
"getScriptName" => "/app_dev.php"
@COil
COil / AppController.php
Last active March 5, 2017 23:47
Request class functions
<?php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class AppController extends Controller
{
/**
* @Route("/my-route", name="blog_test")
/**
* Load all ressources needed for the current website.
*
* @param LoaderInterface $loader
*/
public function registerContainerConfiguration(LoaderInterface $loader)
{
// Load generic configuration
$loader->load(__DIR__.'/config/config.yml');
@COil
COil / gist:79a284e101b5d78e761e
Last active August 29, 2015 14:06
Inline docblock in a foreach statement
<?php
// ...
$awardCount = count($this->finder);
foreach ($this->finder as $file /** @var $file \SplFileInfo */) {
try {
@COil
COil / es.sh
Last active August 29, 2015 14:03
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.2.1.deb
sudo dpkg -i elasticsearch-1.2.1.deb
@COil
COil / gist:5004477
Last active December 14, 2015 01:09
Twig C extension benchmark 2/2
<li>
{% if field.is_selected is defined %}
<input type="checkbox" value="1"{{ html_checked(selected) }} name="{{ name }}" id="{{ id }}" class="{{ class }}">
<label for="{{ id }}">{{ field.element }}</label>
{% endif %}
{% if field.choices is defined %}
<ul>
{% for rankLevel2, subField in field.choices %}
{% include 'ThemesBundle:Search:_group_tree.html.twig' with {