Skip to content

Instantly share code, notes, and snippets.

View hpatoio's full-sized avatar
:shipit:

Simone Fumagalli hpatoio

:shipit:
View GitHub Profile
<?php
/* --- */
/**
* Add players
*
* @param \Acme\DemoBundle\Entity\Player $players
* @return Team
*/
@hpatoio
hpatoio / Team.php
Created February 19, 2013 11:05
Team entity for OneToMany how to
<?php
namespace Acme\DemoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Team
*
* @ORM\Table()
@hpatoio
hpatoio / Player.php
Last active December 13, 2015 22:29
Player entity for OneToMany how to
<?php
namespace Acme\DemoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Player
*
* @ORM\Table()
services:
kernel.listener.force_passupdate :
class: Hpatoio\UserBundle\EventListener\HpatoioForcepassupdateListener
arguments: [@router, @security.context, @session]
tags:
- { name: kernel.event_listener, event: kernel.request, method: onCheckExpired, priority: 1 }
@hpatoio
hpatoio / User.php
Last active December 12, 2015 10:59
User class with property password_changed_at
<?php
namespace Hpatoio\UserBundle\Entity;
use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="fos_user")
@hpatoio
hpatoio / HpatoioForcepassupdateListener.php
Last active June 26, 2018 15:58
Event listener to force FOS user to change password
<?php
namespace Hpatoio\UserBundle\EventListener;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Bundle\FrameworkBundle\Routing\Router;
use Symfony\Component\HttpFoundation\Session\Session;
@hpatoio
hpatoio / gist:4662612
Last active December 11, 2015 21:28
composer.json that let you have Symfony bounded to the latest 2.1 stable version but still be able to install other bundles with dev stability
{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.1.*@stable",
security:
providers:
chain_provider:
chain:
providers: [in_memory, fos_userbundle]
in_memory:
memory:
users:
foo: { password: test }
fos_userbundle:
@hpatoio
hpatoio / gist:4398399
Last active March 15, 2021 02:46
Create a MySQL database and create a user with all grant on it
CREATE USER 'DB_USERNAME'@'localhost' IDENTIFIED BY 'DB_PASSWORD';
GRANT USAGE ON * . * TO 'DB_USERNAME'@'localhost' IDENTIFIED BY 'DB_PASSWORD' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
CREATE DATABASE IF NOT EXISTS `DB_USERNAME` ;
GRANT ALL PRIVILEGES ON `DB_USERNAME` . * TO 'DB_USERNAME'@'localhost';
#For connection from everywhere
GRANT USAGE ON * . * TO 'DB_USERNAME'@'%' IDENTIFIED BY 'DB_PASSWORD' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0
GRANT ALL PRIVILEGES ON `DB_USERNAME` . * TO 'DB_USERNAME'@'%';
server {
listen 80;
server_name www.yourdomain.com
## root
root /path/to/your/document_root/;
## global rewrites