# services.yaml
services:
_defaults:
autowire: true
autoconfigure: true
bind:
$statusCodes: [400, 500]
$logLevel: 'info'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\FeatureFlag\FeatureFlagEnum; | |
trait FeatureFlagEnumTrait | |
{ | |
public static function names() | |
{ | |
return array_column(self::cases(), 'name'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\FeatureFlag\Resolver; | |
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag; | |
// In order to tag all classes that implements this interface | |
#[AutoconfigureTag()] | |
interface FeatureFlagResolverInterface | |
{ | |
public function isEnabled(string $name): bool; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
class BaseHttpClient | |
{ | |
implements HttpClientInterface | |
{ | |
use AsyncDecoratorTrait; | |
public function request(string $method, string $url, array $options = []): ResponseInterface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use App\Bus; | |
class HelloController extends AbstractController | |
{ | |
#[Route('/hello', name: 'app_hello')] | |
public function hello(Bus $bus): Response | |
{ | |
$bus->dispatch(new MyMessage()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// FooPreHandler.php | |
class FooPreHandler implements PreHandlerInterface | |
{ | |
💡 // As it's a service you can inject what you want | |
public function __construct(DummyService $service) {} | |
public function preHandle(object $message) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# services.yaml | |
services: | |
_instanceof: | |
# Add a tag `app.pre_handler` to all classes that implements App\PreHandlerInterface | |
App\PreHandlerInterface: | |
tags: [ 'app.pre_handler' ] | |
# Add a tag `app.post_handler` to all classes that implements App\PostHandlerInterface | |
App\PostHandlerInterface: | |
tags: [ 'app.post_handler' ] | |
_defaults: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\Messenger\MessageBusInterface; | |
final class Bus | |
{ | |
// The trait contains a `handle` method | |
// that dispatch the message and return the result. | |
use Symfony\Component\Messenger\HandleTrait; |
NewerOlder