Skip to content

Instantly share code, notes, and snippets.

View Jibbarth's full-sized avatar
🌴

Jibé Barth Jibbarth

🌴
View GitHub Profile
@dbu
dbu / OAuthEsmtpTransportFactoryDecorator.php
Last active April 18, 2024 13:11
Send emails with Symfony Mailer through Outlook / office365 with OAuth
<?php
declare(strict_types=1);
namespace App\Infrastructure\Email;
use Symfony\Component\Mailer\Transport\Dsn;
use Symfony\Component\Mailer\Transport\Smtp\Auth\AuthenticatorInterface;
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransportFactory;
@lyrixx
lyrixx / ContainerTest.php
Last active August 31, 2023 07:32
Test applications services can boot
<?php
namespace Tests\Integration;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
@mbabker
mbabker / RemoveSyliusMigrationsPass.php
Last active November 10, 2020 07:59
Compiler pass which removes migration paths added by SyliusCoreBundle and SyliusAdminApiBundle (or other third party packages), useful if you are manually managing all migrations within your Sylius application
<?php declare(strict_types=1);
namespace App\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
final class RemoveSyliusMigrationsPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
@ThomasLandauer
ThomasLandauer / SecurityController.php
Last active August 19, 2022 14:19
Magic Link login with Symfony to secure just one route
<?php
// src/Controller/SecurityController.php
namespace App\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
@faizanakram99
faizanakram99 / ArgumentResolverTest.php
Last active October 13, 2021 13:07
RequestDTOArgumentValueResolver
<?php
namespace Qbil\Tests\CommonBundle\Services;
use Qbil\CommonBundle\Services\DTOArgumentValueResolver;
use Qbil\Tests\Fixtures\Controller\DTOController;
use Qbil\Tests\Fixtures\DTO\Person;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ArgumentResolver;
@kunicmarko20
kunicmarko20 / Login.php
Last active March 25, 2024 10:56
Symfony OAuth with Leage OAuth2 library
<?php
declare(strict_types=1);
namespace App;
use Symfony\Component\HttpFoundation\Response;
use Twig\Environment;
use League\OAuth2\Client\Provider\Google as GoogleProvider;
@dbu
dbu / CacheWarmerCompilerPass.php
Last active March 4, 2024 15:13
Conditionally tag a service in Symfony
<?php
// src/DependencyInjection/CacheWarmerCompilerPass.php
namespace App\DependencyInjection;
use App\Cache\MyCacheWarmer;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\EnvNotFoundException;
@calebporzio
calebporzio / pure_html_css_modal.css
Last active February 28, 2022 18:15
The CSS for the pure HTML/CSS modal I tweeted about.
details summary {
cursor: pointer;
outline: none !important;
display: inline-block;
padding: 8px 12px;
padding-top: 10px;
border-radius: 4px;
overflow: hidden;
background: #F09825;
color: white;
@lyrixx
lyrixx / HardCoreDebugLogger.php
Last active April 19, 2024 13:47
Hardcore Debug Logger
<?php
const STREAM_OPEN_FOR_INCLUDE = 128;
final class HardCoreDebugLogger
{
public static function register(string $output = 'php://stdout')
{
register_tick_function(function () use ($output) {
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
@GregoireHebert
GregoireHebert / ApiResourcesConvertConfigurationCommand.php
Last active November 3, 2022 14:11
Transform ApiResource configuration to XML
<?php
declare(strict_types=1);
namespace App\Command;
use App\Command\DataTransformers\XmlTransformer;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;