PHP code example of robiningelbrecht / symfony-skeleton

1. Go to this page and download the library: Download robiningelbrecht/symfony-skeleton library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

robiningelbrecht / symfony-skeleton example snippets


class User
{
    use RecordsEvents;
    
    public static function create(
        UserId $id,
    ): self {
        // ...
        $user->recordThat(new UserWasCreated(
            userId: $user->getUserId(),
        ));

        return $user;
    }
}

final readonly class UserRepository implements CommandHandler
{
    public function __construct(
        private EventBus $eventBus,
    ) {
    }
    
    public function save(User $user): void
    {
        // ...
        $this->eventBus->publishEvents($user->getRecordedEvents());
    }    


final readonly class UserEmailManager
{
    #[AsEventListener]
    public function reactToUserWasCreated(UserWasCreated $event): void
    {
        // ...
    }
}

    #[RateLimiter('anonymous')]
    #[Route(path: '/your/important/route', methods: ['GET', 'POST'])]
    public function handle(Request $request): Response
    {
      // ...
    }