Skip to content

Instantly share code, notes, and snippets.

@chrisguitarguy
Last active August 23, 2019 20:42
Show Gist options
  • Select an option

  • Save chrisguitarguy/88cf096adadb470aae066fcca2d17d6f to your computer and use it in GitHub Desktop.

Select an option

Save chrisguitarguy/88cf096adadb470aae066fcca2d17d6f to your computer and use it in GitHub Desktop.
<?php
class ClientDto
{
public $id;
public $name;
public $site_url;
}
<?php
class Client
{
private $id;
private $name;
private $siteUrl;
// constructor, getters, etc
}
<?php
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class ClientController extends AbstractController
{
public function viewClientAction(string $clientId) : Response
{
$client = $this->getClientOr404($clientId);
return $this->json(ClientDto::fromClient($client));
}
}
<?php
abstract class Dto
{
const GROUP_DEFAULT = 'default';
const GROUP_CREATE = 'create';
const GROUP_UPDATE = 'update';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment