Skip to content

Instantly share code, notes, and snippets.

View Neirda24's full-sized avatar
🍺
🍺

Adrien Roches Neirda24

🍺
🍺
View GitHub Profile
@Neirda24
Neirda24 / src\Rector\AddFormInterfaceGenericToTwigComponentWithFormRector.php
Created April 24, 2025 12:24
Rector rule to add the `@return FormInterface<TData>` on twig component with form trait on method `instantiateForm`
<?php
declare(strict_types=1);
namespace Utils\Rector\Rector;
use PhpParser\Comment\Doc;
use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\TraitUse;
@Neirda24
Neirda24 / src\Rector\AddGenericToAbstractTypeRector.php
Created April 23, 2025 17:27
Rector rule to add the `@extends AbstractType<TData>` on forms based on `data_class`
<?php
declare(strict_types=1);
namespace Utils\Rector\Rector;
use PhpParser\Comment\Doc;
use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Expr\Array_;
composer require symfony/type-info
composer require symfony/json-encoder
composer require symfony/emoji
composer require symfony/asset-mapper symfony/asset symfony/twig-pack
block importmap('app')
php bin/console asset-map:compile
php bin/console importmap:require bootstrap
$response $this->client->request('GET','https://...')
$this->client $client->withOptions (HttpOptions())->setBaseUri('https://...')
@Neirda24
Neirda24 / docker-compose.local.traefik.yml
Last active October 18, 2022 10:40
multiple docker-compose structure (light)
services:
nginx:
networks:
traefik:
aliases:
- 'local.app'
labels:
traefik.enable: 'true'
traefik.http.services.myapp.loadbalancer.server.port: '80'
traefik.http.routers.myapp.rule: 'Host(`local.app`)'
@Neirda24
Neirda24 / functions.sh
Last active November 16, 2022 12:17
Seamless docker integration
#!/usr/bin/env bash
## ---------------
## Setup
## ---------------
CURRENT_BASH=$(ps -p $$ | tail -n 1 | awk '{ print $4 }' | perl -pe 's#.*[-/](\w)#$1#');
case "${CURRENT_BASH}" in
zsh)
CURRENT_DIR=$(cd "$(dirname "${0}")" && pwd);
;;
NGROK_AUTH=My_auth_token
@Neirda24
Neirda24 / README.md
Created May 1, 2020 08:57
Seemless use of docker

Usage

$ # Depending on your terminal (sh, bash, zsh) it may display errors or warning. But it will work ;)
$ source ./functions.sh
$ php --version # execute php inside the container and accept any arguments
$ dev # execute the symfony console on dev mode and accept any arguments
FROM scratch as app
WORKDIR /app
COPY . .
RUN chmod +x docker-entrypoint.sh
FROM whatever
@Neirda24
Neirda24 / OverrideFosRestServicesPass.php
Created November 29, 2018 14:31
Override service with CompilerPass
<?php
class OverrideFosRestServicesPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
if ($container->hasDefinition('fos_rest.exception_listener')) {
@Neirda24
Neirda24 / 1-Dockerfile.common
Created February 5, 2018 17:10
usecase for include
ARG SOURCE=mysource
FROM ${CODE_VERSION}
#some common actions
RUN ...