Skip to content

Instantly share code, notes, and snippets.

@azhararmar
azhararmar / Symfony - Manual User Authentication
Last active June 21, 2024 08:44
Manually Authenticate User In Symfony
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
// Manually authenticate user in controller
$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
$this->get('security.token_storage')->setToken($token);
$this->get('session')->set('_security_main', serialize($token));
@alrayyes
alrayyes / Remove all containers based on Docker image name.md
Last active October 6, 2018 07:40
Remove all containers based on Docker image name
@joshavg
joshavg / DatalistType.php
Created May 20, 2016 15:30
Datalist in Symfony
<?php
namespace Acme\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class DatalistType extends AbstractType
{
@odan
odan / xampp_php7_xdebug.md
Last active October 19, 2024 04:15
Installing Xdebug for XAMPP
@vrushank-snippets
vrushank-snippets / Extract emails from a string
Created March 23, 2012 10:59
PHP : Extract emails from a string
function extract_emails($str){
// This regular expression extracts all emails from a string:
$regexp = '/([a-z0-9_\.\-])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i';
preg_match_all($regexp, $str, $m);
return isset($m[0]) ? $m[0] : array();
}
$test_string = 'This is a test string...