Renato Mefi @renatomefi
query radWithSymfony {
person(id: "renatomefi") {
name
twitter
company
bioPerLine
}
talk(id: "rad-symfony") {
title
date
type
}
}
{
"data": {
"person": {
"name": "Renato Mendes Figueiredo",
"twitter": "@renatomefi",
"company": "@usabilla",
"bioPerLine": [
"ZCE, ZCPE, ZFCE, LPIC-1, LFCS, LFCE Professional",
"a.k.a.: A guy who loves linux and software dev!",
"Co-organizer of @PHPAmersfoort and @rumoazcephp",
"Maintainer of php-vcr and OverblogGraphQLBundle"
]
},
"talk": {
"title": "RAD With Symfony",
"date": "2018-06-08T12:40:00.042Z",
"type": "fwdays 2018"
}
}
}
# git clone https://github.com/spring-projects/spring-boot.git ## Or spring roo/cli
# cd to a sample
# mvn package && java -jar target/gs-spring-boot-0.1.0.jar
Completely running, in memory data storage with Spring Data
# composer create-project symfony/skeleton my-project && cd my-project
# php -S 127.0.0.1:8000 -t public ## or use symfony server
composer require maker --dev
package sample.hateoas;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication <===========
public class SampleHateoasApplication {
public static void main(String[] args) {
SpringApplication.run(SampleHateoasApplication.class, args);
}
}
app.mailer.default:
class: Mailer
arguments: ['%mailer.transport%']
app.controller.hello:
class: \App\Controller\HelloController
arguments: ['@mailer']
app.repository.user:
class: \App\Repository\UserRepository
app.service.process.hello:
class: \App\Services\HelloProcessor
arguments: ['@app.repository.user']
app.controller.hello:
class: \App\Controller\HelloController
arguments: ['@app.service.process.hello']
services:
_defaults:
autowire: true
App\:
resource: '../src/*'
exclude: '../src/{Entity,Migrations,Tests,Kernel.php}'
final class RepositoryA
{
...
}
final class ServiceA
{
...
public function __construct(RespositoryA $repositoryA)
{
$this->repository = $repositoryA;
}
...
}
final class ControllerA
{
...
public function __construct(ServiceA $serviceA)
{
$this->service = $serviceA;
}
...
}
Text/Replace App *.php
"autoload": {
"psr-4": {
"Fwdays\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"FwdaysTests\\": "tests/"
}
},
Fwdays\:
resource: '../src/*'
exclude: '../src/{Entity,Migrations,Tests,Kernel.php}'
Fwdays\Application:
resource: '../src/Domain/*'
Fwdays\Domain:
resource: '../src/Domain/*'
Fwdays\Infrastructure:
resource: '../src/Infrastructure/*'
// src/Model/User.php
class User
{
/**
* @Assert\NotBlank()
* @Assert\Type("string")
*/
public $name;
}
// src/Domain/User.php
final class User
{
private $name;
public function __construct(string $name) {
Assert::notBlank($name);
$this->name = $name;
}
}
final class Name
{
private $value;
public function __construct(string $value) {
Assert::notBlank($name);
$this->value = $value;
}
public function getName(): string
{
return $this->value;
}
}
final class User
{
private $name;
private $email;
public function __construct(Name $name, Email $email) {
$this->name = $name;
$this->email = $email;
}
}
# depfile.yml
paths:
- ./src
exclude_files:
- .*test.*
layers:
- name: Controller
collectors:
- type: className
regex: .*Controller.*
- name: Repository
collectors:
- type: className
regex: .*Repository.*
- name: Service
collectors:
- type: className
regex: .*Service.*
ruleset:
Controller:
- Service
Service:
- Repository
Repository: ~
$definitionBuilder = new DefinitionBuilder();
$definition = $definitionBuilder->addPlaces(['opening', 'talks', 'lunch', 'speakers_panel'])
->addTransition(new Transition('to_talks', 'opening', 'talks'))
->addTransition(new Transition('hungry', 'talks', 'lunch'))
->addTransition(new Transition('cool', 'talks', 'speakers_panel'))
->build()
;
$workflow->apply($you, 'to_talks');
$workflow->apply($you, 'hungry');
$workflow->apply($you, 'cool'); // TransitionException
http://talks.mefi.in/rad-symfony-fwdays2018