Skip to content

Instantly share code, notes, and snippets.

View asentner's full-sized avatar

Adam Sentner asentner

View GitHub Profile
@asentner
asentner / ExampleFormType.php
Last active September 13, 2015 01:50
Symfony FieldsetType using anonymous functions instead of arrays
<?php
namespace Acme\DemoBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;
class ExampleFormType extends AbstractType
@asentner
asentner / remove-php-short-tags.pl
Last active February 7, 2017 12:25
Script to remove php short tags and replace with full opening tags <? to <?php
#!/usr/bin/env perl
use strict;
use warnings;
use Carp;
use File::Find::Rule;
use File::Basename;
my ($path) = @ARGV;
@asentner
asentner / DatabaseSessionHandler.php
Last active February 17, 2017 12:47
Session handler using a PDO connection to read/write session data to the database on Symfony and Laravel projects. Compatible with MySQL (innodb databases) and PostgreSQL 9.5+. If the database connection fails, this essentially becomes a NullSessionHandler and doesn't write a session at all.
<?php
namespace Acme\DemoBundle\Session\Storage\Handler;
/**
* Session handler using a PDO connection to read/write session data to the database on Symfony and
* Laravel projects.
*
* This script is intended to work with MySQL (innodb databases) and PostgreSQL 9.5+.
*
#!/bin/bash
_console()
{
local cur prev script
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
script="${COMP_WORDS[0]}"