Skip to content

Instantly share code, notes, and snippets.

View adamsafr's full-sized avatar
🏠

Adam Sapraliev adamsafr

🏠
View GitHub Profile
@onomatopellan
onomatopellan / wsl.conf
Last active December 19, 2023 09:09
/etc/wsl.conf Avoid adding Windows Path to Linux $PATH
[interop]
appendWindowsPath=false
@carstenwindler
carstenwindler / xdebug.sh
Last active February 6, 2024 08:20
Bash script to quickly enable / disable xdebug in a PHP docker container
#!/usr/bin/env bash
# see https://carstenwindler.de/php/enable-xdebug-on-demand-in-your-local-docker-environment/
if [ "$#" -ne 1 ]; then
SCRIPT_PATH=`basename "$0"`
echo "Usage: $SCRIPT_PATH enable|disable"
exit 1;
fi
# Expects service to be called app in docker-compose.yml
@BoShurik
BoShurik / PostModel.php
Created April 3, 2019 19:26
UniqueModel
namespace App\Post\Model;
use App\Model\Validator\Constraints\UniqueModel;
/**
* @UniqueModel(class="App\Entity\Post", fields={"user": "user", "slug": "slug"})
*/
class PostModel
{
public $user;
@Xymanek
Xymanek / Readme.md
Last active February 17, 2022 13:52
UniqueDto validator

It can

  • properly deal with multi-fields uniqueness checks (and composite PKs)
  • use symfony's property path or directly private properties
  • does not cause hydration when checking
  • allows to optionally map to existing entity (by having it as property) or by mapping id fields (or none at all so any matching record will trigger a failure)
  • allows to re-map fields between DTO and entity (eg. fields={"display_name": "username"}). Combined with sf property accessor this allows for "virtual properties". This also works for id fields
  • load the violating record to show in debug panel. Example http://prntscr.com/i3ifbn
  • not get confused if multiple violating records are found
@ostrolucky
ostrolucky / ColumnHydrator.php
Last active January 3, 2022 11:53
Doctrine ColumnHydrator
<?php
declare(strict_types=1);
namespace App\ORM\Hydration;
use Doctrine\ORM\Internal\Hydration\ArrayHydrator;
/**
* Returns one-dimensional scalar array from query: mixed[][] => mixed[]
@zmts
zmts / tokens.md
Last active May 7, 2024 18:21
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@midascodebreaker
midascodebreaker / laravel-per-project-installation.md
Last active March 15, 2022 10:09
Laravel Homestead per Project Installation on Windows 10
Prerequisite:
  • Php7
  • Composer
  • Gulp
  • Npm
  • Vagrant
  • Virtual Box
  • Laravel Installer
@nepsilon
nepsilon / git-change-commit-messages.md
Last active April 24, 2024 06:30
How to change your commit messages in Git? — First published in fullweb.io issue #55

How to change your commit messages in Git?

At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent or burried below 10 other commits, but fear not, git has your back 🙂.

Not pushed + most recent commit:

git commit --amend

This will open your $EDITOR and let you change the message. Continue with your usual git push origin master.

@fesor
fesor / README.md
Last active July 22, 2023 23:00
Symfony Request Object

Symfony Request Object

This is proof-of-concept implementation of laravel's like form requests.

Rational

Most of Symfony developers uses forms to map request data to some Data Transfer Object. This object then passes to validator and system start to work with validated data converted to be compatible with application model.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>