Skip to content

Instantly share code, notes, and snippets.

View faizanakram99's full-sized avatar
💭
PHPing(SYMFONYing) all the time

Faizan Akram Dar faizanakram99

💭
PHPing(SYMFONYing) all the time
View GitHub Profile
@faizanakram99
faizanakram99 / DialogPopover.html.twig
Created September 11, 2024 00:09
Lightbox (popver) twig component
<div popover id="{{ id }}" {{ attributes.defaults({class: 'pop-over dialog-popover'}) }}>
<div class="md-card h-100">
{% block dialog_header %}
<div class="card-header">{{ title|trans|capitalize }}
<button type="button" class="icon-button" popovertargetaction="hide"
popovertarget="{{ id }}">
<span class="icon icon-cancel"></span>
</button>
</div>
{% endblock %}
@faizanakram99
faizanakram99 / CrossTenantQueryRunner.php
Last active September 5, 2024 19:24
PHP async mysql
<?php
declare(strict_types=1);
namespace Xoxo;
class CrossTenantQueryRunner
{
private const EXCLUDED_TENANTS = ['demo', 'sandbox'];
/**
@faizanakram99
faizanakram99 / AccessTokenHandler.php
Last active August 27, 2024 20:16
Enums as an alternative to exceptions
<?php
declare(strict_types=1);
namespace Qbil\Infrastructure\Http\Security;
use Zzz\Infrastructure\Http\InvalidToken;
use Zzz\Infrastructure\Http\Token;
use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
use Symfony\Component\Security\Http\AccessToken\AccessTokenHandlerInterface;
@faizanakram99
faizanakram99 / PHP ADT coolness (pseudo code).md
Created June 24, 2024 23:06
PHP ADT coolness (pseudo code).md

PHP Examples: OOP vs ADT with Pattern Matching by ChatGPT

OOP Approach: Strategy Pattern

<?php

// OOP Approach with Interfaces and Classes
@faizanakram99
faizanakram99 / GraphQLiteClassesFinder.php
Created May 30, 2024 22:39
Kcs Finder Interface performant implementation for graphqlite symfony bundle
<?php
declare(strict_types=1);
namespace Yay;
use Kcs\ClassFinder\Finder\FinderInterface;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\Finder\Finder;
@faizanakram99
faizanakram99 / AbstractTranslationRepository.php
Last active May 31, 2024 09:41
Single entity with multiple entity manager (a real production code example)
<?php
declare(strict_types=1);
namespace Tld\Translation\Infrastructure\Doctrine\Repository;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Tld\Translation\Domain\Entity\Translation;
@faizanakram99
faizanakram99 / QueryHydrator.php
Created January 20, 2024 00:15
DBAL results to object hydrator
<?php
declare(strict_types=1);
namespace HakunaMatata;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Query\QueryBuilder;
use Doctrine\DBAL\Types\Type;
@faizanakram99
faizanakram99 / TranslationConfigCacheFactory.php
Created June 30, 2022 16:09
Example of ConfigCacheFactory for overriding translation cache for multi-tenant app with tenant specific translations
<?php
namespace Yup\Translation;
use Symfony\Component\Config\ConfigCacheFactoryInterface;
use Symfony\Component\Config\ConfigCacheInterface;
class TranslationConfigCacheFactory implements ConfigCacheFactoryInterface
{
private ConfigCacheFactoryInterface $configCacheFactory;
@faizanakram99
faizanakram99 / MonospaceResponse.php
Created November 18, 2020 12:02
View Monolog in browser with HttpFoundation component
<?php
declare(strict_types=1);
namespace Qbil\CommonBundle\Extension;
use Symfony\Component\HttpFoundation\Response;
use Webmozart\Assert\Assert;
final class MonospaceResponse extends Response
name: Code check
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]
types: [ synchronize, opened, reopened, ready_for_review ]
jobs: