PHP code example of antonyan / ddd-mappers-project

1. Go to this page and download the library: Download antonyan/ddd-mappers-project 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/ */

    

antonyan / ddd-mappers-project example snippets


/** 
     * @Validation(name="phone", type="string", ed=true, maxLength=100)
     * @Validation(name="firstName", type="string", sonResponse
     */
    public function create(Request $request): CreateEntityJsonResponse
    {
        return new CreateEntityJsonResponse($this->getUserService()->create($request->request->all())->toArray());
    }
/src/app/config/restRoutes.php

    public function create(array $data): UserAggregate
    {
        return $this->getUserAggregateService()->create($data);
    } 

    private function getUserService(): UserContract
    {
        return $this->container()->get('UserService');
    }



namespace Contexts\Test;

use Infrastructure\Models\ArraySerializable;

class SomeModel implements ArraySerializable
{
    public const ID = 'id';
    public const PHONE = 'phone';
    public const EMAIL= 'email';

    /**
     * @var int
     */
    private $id;

    /**
     * @var string
     */
    private $phone;

    /**
     * @var string
     */
    private $email;

    /**
     * SomeModel constructor.
     * @param int $id
     * @param string $phone
     * @param string $email
     */
    public function __construct(
        int $id,
        string $phone,
        string $email
    )
    {
        $this->id = $id;
        $this->phone = $phone;
        $this->email = $email;
    }

    /**
     * @return array
     */
    public function toArray(): array
    {
        return [
            self::ID => $this->id,
            self::EMAIL => $this->email,
            self::PHONE => $this->phone,
        ];
    }
}
src/app/config/appContainer.php
$containerBuilder->register('application.error.handler', \App\Services\Error::class);