Skip to content

Instantly share code, notes, and snippets.

View alOneh's full-sized avatar

Alain Hippolyte alOneh

  • @sensiolabscc
  • Paris, France
View GitHub Profile
@alOneh
alOneh / twig_templates_used.sh
Last active February 14, 2018 16:35
Little script to retrieve the templates used in you Symfony App
#!/bin/bash
# escape the slash in document root
DOCUMENT_ROOT=\/var\/www\/html\/
SYMFONY_ENV=dev
# The full path is written by the Twig compiler, generally at the end of the cache file in the getSourceContext() method
grep -RhoP "${DOCUMENT_ROOT}.*\.html\.twig" app/cache/${SYMFONY_ENV}/twig/ | grep -v vendor
<?php
namespace App\Faker\Provider;
use libphonenumber\NumberParseException;
use libphonenumber\PhoneNumber;
use libphonenumber\PhoneNumberUtil;
use libphonenumber\PhoneNumberFormat;
class PhoneNumberProvider
@alOneh
alOneh / CsvReader.php
Created January 31, 2019 10:50
A CsvReader with utf8 encoding
<?php declare(strict_types=1);
namespace App\CSV;
use League\Csv\Reader;
use League\Csv\Statement;
use voku\helper\UTF8;
class CsvReader
{
@alOneh
alOneh / User.php
Created March 7, 2019 17:03
How to serialize User information in session
<?php
class User implements UserInterface, \Serializable
{
/**
* {@inheritdoc}
*/
public function serialize(): string
{
return serialize([$this->id, $this->username, $this->password]);
@alOneh
alOneh / DashboardApp.vue
Last active November 13, 2024 03:41
Example of a Vue.js app integrated in a twig template
<template>
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-green"><i class="fa fa-users"/></span>
<div class="info-box-content">
<span class="info-box-text">Active users</span>
<span class="info-box-number">{{ usersCount || 0 }}</span>
</div>
</div>
<?php
// tests/App/ReflectionTrait.php
namespace App\Tests;
trait ReflectionTrait
{
/**
* @param $object
* @param $methodName
* @param array $parameters