Skip to content

Instantly share code, notes, and snippets.


Craig Marvelley craigmarvelley

View GitHub Profile
craigmarvelley / Web.config
Created May 8, 2011
Silex IIS Web.config
View Web.config
<?xml version="1.0"?>
<clear />
<add value="index.php" />
craigmarvelley / commands.txt
Created May 11, 2011
Setting up a Symfony 2 project with bleeding edge vendors on Windows
View commands.txt
git init
mkdir vendor
git submodule add git:// vendor/assetic
mkdir vendor\bundles\JMS
git submodule add vendor/bundles/JMS/SecurityExtraBundle
mkdir vendor\bundles\Sensio\Bundle
craigmarvelley / gist:1339292
Created Nov 4, 2011
Titanium 1.7.5 and underscore.string.js
View gist:1339292
// (Starting line 446)
// CommonJS module is defined
if (typeof module !== 'undefined' && module.exports) {
// Export module
module.exports = _s;
// Added: Support Titanium's CommonJS implementation)
} else if (typeof exports !== 'undefined' && exports) {
exports._s = _s;
craigmarvelley / gist:2047834
Created Mar 16, 2012
Symfony & PHPCR composer.json
View gist:2047834
"name": "symfony/framework-standard-edition",
"autoload": {
"psr-0": { "": "src/" }
"require": {
"php": ">=5.3.2",
"symfony/symfony": "2.1.*",
"doctrine/orm": "2.2.*",
"doctrine/doctrine-bundle": "dev-master",
craigmarvelley /
Created Nov 2, 2012 — forked from rajraj/
Install ElasticSearch on CentOS 6
cd ~
sudo yum update
sudo yum install java-1.7.0-openjdk -y
wget -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
craigmarvelley / IsAdminFieldSubscriber.php
Created Nov 10, 2012
Symfony2 Form Event Subscriber Example
View IsAdminFieldSubscriber.php
namespace Acme\Bundle\AppBundle\Form\EventListener;
use Symfony\Component\Form\Event\DataEvent;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormEvents;
class IsAdminFieldSubscriber implements EventSubscriberInterface
View XHRAuthenticationFailureHandler.php
namespace Acme\DemoBundle\Handler;
use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationFailureHandler;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
class XHRAuthenticationFailureHandler extends DefaultAuthenticationFailureHandler
View index.js
$(document).ajaxError(function (e, xhr, settings, exception) {
// If we don't have a valid session, show a login form
if (xhr.status === STATUS_CODE_UNAUTHORIZED || xhr.status === STATUS_CODE_FORBIDDEN) {
View index.js
$.ajax('login', {
success: function (response) {
var csrf = $('<div/>').append(response).find('input[name="_csrf_token"]').val();
if (!csrf) {
throw 'Failed to parse CSRF value';
$.ajax('login_check', {
type: "POST",
View EntityHiddenType.php
namespace Dpn\ToolsBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Dpn\ToolsBundle\Form\DataTransformer\EntityToIdTransformer;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Doctrine\Common\Persistence\ObjectManager;