Skip to content

Instantly share code, notes, and snippets.

class TokenGenerator
{
private const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
public function getRandomSecureToken(int $length): string
{
$maxNumber = strlen(self::ALPHABET);
$token = '';
for ($i = 0; $i < $length; $i++) {
class Mailer
{
/**
* @var \Swift_Mailer
*/
private $mailer;
/**
* @var \Twig_Environment
*/
private $twig;
@lasekmiroslaw
lasekmiroslaw / composer.json
Created June 27, 2018 18:38
composer command reset db
"scripts": {
"reset-db": [
"php bin/console doctrine:schema:drop --force; php bin/console doctrine:schema:create; php bin/console hautelook:fixtures:load -n;"
]
}
@lasekmiroslaw
lasekmiroslaw / Dockerfile
Last active March 3, 2019 15:22
Xdebug docker phpstorm
# Configure xdebug
RUN echo $'error_reporting=E_ALL \n\
display_startup_errors=On \n\
display_errors=On \n\
xdebug.remote_enable=1 \n\
xdebug.remote_connect_back=1\n\
xdebug.idekey=PHPSTORM \n\
xdebug.remote_autostart=0 \n\
xdebug.remote_port=5902' >> /etc/php.d/15-xdebug.ini
@lasekmiroslaw
lasekmiroslaw / gist:46badee59c1b6bcc182562a372917c76
Last active July 24, 2018 19:58
docker mysql + phpmyadmin
version: '2'
services:
db:
image: mysql:5.7
ports:
- "3306:3306"
volumes:
- ./mysqldata:/var/lib/mysql:rw,delegated
environment:
MYSQL_ROOT_PASSWORD: "root"
@lasekmiroslaw
lasekmiroslaw / gist:d0298fec67813b0559f3b1f00ee58482
Last active July 24, 2018 19:58
password hash eventlistener symfony doctrine
<?php
namespace App\EventListener;
use Doctrine\ORM\Event\LifecycleEventArgs;
use App\Entity\User;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
class PasswordHashListener
{
private $passwordEncoder;
public function __construct(UserPasswordEncoderInterface $passwordEncoder)
{
@lasekmiroslaw
lasekmiroslaw / gist:e79bb36a9aa7bb1d8f7ad60698496a7a
Last active June 23, 2019 10:13
linux useful bash alias command
cerate your bash aliases
gedit ~/.bashrc
update it
source ~/.bashrc
# docker-compose
alias dcu='docker-compose up --d'
alias dcub='docker-compose up --build'
alias dcd='docker-compose down'
alias dcb='docker-compose build'
@lasekmiroslaw
lasekmiroslaw / datetime.sql
Created July 24, 2018 19:55
mysql course
create column auto update timestamp:
CREATE TABLE comments2 (
content VARCHAR(100),
changed_at TIMESTAMP DEFAULT NOW() ON UPDATE CURRENT_TIMESTAMP
);
Date Math:
SELECT birthdt, birthdt + INTERVAL 15 MONTH + INTERVAL 10 HOUR FROM people;
Date Format
@lasekmiroslaw
lasekmiroslaw / files.php
Created July 26, 2018 15:53
php working with files
IMAGES :
<?php<?php
trytry { {
//// Create a new SimpleImage object Create
$image = new \claviska\SimpleImage();
// Magic! ✨
$image
->fromFile('image.jpg') // load image.jpg
@lasekmiroslaw
lasekmiroslaw / composer.txt
Last active August 25, 2018 17:46
composer versions and Constraints, update #composer
https://getcomposer.org/doc/articles/versions.md#writing-version-constraints
1.0 - 2.0 is equivalent to >=1.0.0 <2.1
~1.2 is equivalent to >=1.2 <2.0.0, while ~1.2.3 is equivalent to >=1.2.3 <1.3.0
^1.2.3 is equivalent to >=1.2.3 <2.0.0 as none of the releases until 2.0 should break backwards compatibility.
pre-1.0 versions it also acts with safety in mind and treats ^0.3 as >=0.3.0 <0.4.0
1.2.3 =1.2.3.0-stable
>1.2 >1.2.0.0-stable