More than Just Lines on a Map: Best Practices for U.S Bike Routes
Slides componentes
1. Componentes
El arma secreta de Symfony
#sf2Vigo Javier López | @loalf
2. Javier López
Nací en Córdoba, España.
Vivo en Londres, Reino Unido.
Trabajo en IPC Media (http://ipcmedia.com).
Escribo (a veces) en mi blog (http://www.loalf.com).
Twitteo como @loalf
... ¿quiéres saber más? http://www.linkedin.com/in/loalf
58. buscando archivos por nombre
use SymfonyComponentFinderFinder;
$files = Finder::create()
59. buscando archivos por nombre
use SymfonyComponentFinderFinder;
$files = Finder::create()
->name("*.php")
60. buscando archivos por nombre
use SymfonyComponentFinderFinder;
$files = Finder::create()
->name("*.php")
->name("*.{php,yml}")
61. buscando archivos por nombre
use SymfonyComponentFinderFinder;
$files = Finder::create()
->name("*.php")
->name("*.{php,yml}")
->name("/.(php|yml)$/")
62. buscando archivos por nombre
use SymfonyComponentFinderFinder;
$files = Finder::create()
->name("*.php")
->name("*.{php,yml}")
->name("/.(php|yml)$/")
->name("/^w{3,10}$/")
63. buscando archivos por nombre
use SymfonyComponentFinderFinder;
$files = Finder::create()
->name("*.php")
->name("*.{php,yml}")
->name("/.(php|yml)$/")
->name("/^w{3,10}$/")
->name("foo.php")
64. buscando archivos por nombre
use SymfonyComponentFinderFinder;
$files = Finder::create()
->name("*.php")
->name("*.{php,yml}")
->name("/.(php|yml)$/")
->name("/^w{3,10}$/")
->name("foo.php")
->in(__DIR__);
65. buscando archivos por nombre
use SymfonyComponentFinderFinder;
$files = Finder::create()
->name("*.php")
->name("*.{php,yml}")
->name("/.(php|yml)$/")
->name("/^w{3,10}$/")
->name("foo.php")
->in(__DIR__);
Referencia sobre Patrones Glob: http://cowburn.info/2010/04/30/glob-patterns/
68. buscando archivos por tamaño
use SymfonyComponentFinderFinder;
$files = Finder::create()
69. buscando archivos por tamaño
use SymfonyComponentFinderFinder;
$files = Finder::create()
->size("> 10k")
70. buscando archivos por tamaño
use SymfonyComponentFinderFinder;
$files = Finder::create()
->size("> 10k")
->size("<= 4mi")
71. buscando archivos por tamaño
use SymfonyComponentFinderFinder;
$files = Finder::create()
->size("> 10k")
->size("<= 4mi")
->size("2gi")
72. buscando archivos por tamaño
use SymfonyComponentFinderFinder;
$files = Finder::create()
->size("> 10k")
->size("<= 4mi")
->size("2gi")
->in(__DIR__);
73. buscando archivos por tamaño
use SymfonyComponentFinderFinder;
$files = Finder::create()
->size("> 10k")
->size("<= 4mi")
->size("2gi")
->in(__DIR__);
k = 1000 ki = 1024
m = 1000^2 mi = 1024^2
g = 1000^3 gi = 1024^3
76. buscando archivos por fecha
use SymfonyComponentFinderFinder;
$files = Finder::create()
77. buscando archivos por fecha
use SymfonyComponentFinderFinder;
$files = Finder::create()
->date("since yesterday")
78. buscando archivos por fecha
use SymfonyComponentFinderFinder;
$files = Finder::create()
->date("since yesterday")
->date("until 2 days ago")
79. buscando archivos por fecha
use SymfonyComponentFinderFinder;
$files = Finder::create()
->date("since yesterday")
->date("until 2 days ago")
->date("> now - 2 hours")
80. buscando archivos por fecha
use SymfonyComponentFinderFinder;
$files = Finder::create()
->date("since yesterday")
->date("until 2 days ago")
->date("> now - 2 hours")
->date(">= 2005-10-15 ")
81. buscando archivos por fecha
use SymfonyComponentFinderFinder;
$files = Finder::create()
->date("since yesterday")
->date("until 2 days ago")
->date("> now - 2 hours")
->date(">= 2005-10-15 ")
->in(__DIR__);
82. buscando archivos por fecha
use SymfonyComponentFinderFinder;
$files = Finder::create()
->date("since yesterday")
->date("until 2 days ago")
->date("> now - 2 hours")
->date(">= 2005-10-15 ")
->in(__DIR__);
Parámetro es cualquier argumento válido para strtotime()
106. archivos php en la carpeta raíz del proyecto
use SymfonyComponentFinderFinder;
107. archivos php en la carpeta raíz del proyecto
use SymfonyComponentFinderFinder;
$files = Finder::create()
108. archivos php en la carpeta raíz del proyecto
use SymfonyComponentFinderFinder;
$files = Finder::create()
->files()
109. archivos php en la carpeta raíz del proyecto
use SymfonyComponentFinderFinder;
$files = Finder::create()
->files()
->depth(0)
110. archivos php en la carpeta raíz del proyecto
use SymfonyComponentFinderFinder;
$files = Finder::create()
->files()
->depth(0)
->name("*.php")
111. archivos php en la carpeta raíz del proyecto
use SymfonyComponentFinderFinder;
$files = Finder::create()
->files()
->depth(0)
->name("*.php")
->in(__DIR__);
150. mostrando sólo los tiempos
use SymfonyComponentProcessProcess;
$process = new Process('ping -c 4 twitter.com');
151. mostrando sólo los tiempos
use SymfonyComponentProcessProcess;
$process = new Process('ping -c 4 twitter.com');
$process->run(function($type, $buffer) {
152. mostrando sólo los tiempos
use SymfonyComponentProcessProcess;
$process = new Process('ping -c 4 twitter.com');
$process->run(function($type, $buffer) {
if('out' === $type){
153. mostrando sólo los tiempos
use SymfonyComponentProcessProcess;
$process = new Process('ping -c 4 twitter.com');
$process->run(function($type, $buffer) {
if('out' === $type){
$pattern = '/time=(d+.d+) ms/';
154. mostrando sólo los tiempos
use SymfonyComponentProcessProcess;
$process = new Process('ping -c 4 twitter.com');
$process->run(function($type, $buffer) {
if('out' === $type){
$pattern = '/time=(d+.d+) ms/';
if(preg_match_all($pattern, $buffer, $matches)){;
155. mostrando sólo los tiempos
use SymfonyComponentProcessProcess;
$process = new Process('ping -c 4 twitter.com');
$process->run(function($type, $buffer) {
if('out' === $type){
$pattern = '/time=(d+.d+) ms/';
if(preg_match_all($pattern, $buffer, $matches)){;
print $matches[0][0]."n";
156. mostrando sólo los tiempos
use SymfonyComponentProcessProcess;
$process = new Process('ping -c 4 twitter.com');
$process->run(function($type, $buffer) {
if('out' === $type){
$pattern = '/time=(d+.d+) ms/';
if(preg_match_all($pattern, $buffer, $matches)){;
print $matches[0][0]."n";
}
157. mostrando sólo los tiempos
use SymfonyComponentProcessProcess;
$process = new Process('ping -c 4 twitter.com');
$process->run(function($type, $buffer) {
if('out' === $type){
$pattern = '/time=(d+.d+) ms/';
if(preg_match_all($pattern, $buffer, $matches)){;
print $matches[0][0]."n";
}
}elseif( 'err' === $type ){
158. mostrando sólo los tiempos
use SymfonyComponentProcessProcess;
$process = new Process('ping -c 4 twitter.com');
$process->run(function($type, $buffer) {
if('out' === $type){
$pattern = '/time=(d+.d+) ms/';
if(preg_match_all($pattern, $buffer, $matches)){;
print $matches[0][0]."n";
}
}elseif( 'err' === $type ){
print "Twitter esta offline";
159. mostrando sólo los tiempos
use SymfonyComponentProcessProcess;
$process = new Process('ping -c 4 twitter.com');
$process->run(function($type, $buffer) {
if('out' === $type){
$pattern = '/time=(d+.d+) ms/';
if(preg_match_all($pattern, $buffer, $matches)){;
print $matches[0][0]."n";
}
}elseif( 'err' === $type ){
print "Twitter esta offline";
}
160. mostrando sólo los tiempos
use SymfonyComponentProcessProcess;
$process = new Process('ping -c 4 twitter.com');
$process->run(function($type, $buffer) {
if('out' === $type){
$pattern = '/time=(d+.d+) ms/';
if(preg_match_all($pattern, $buffer, $matches)){;
print $matches[0][0]."n";
}
}elseif( 'err' === $type ){
print "Twitter esta offline";
}
});
165. Búsqueda en Twitter
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://search.twitter.com/search.atom?q=sf2vigo';
166. Búsqueda en Twitter
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://search.twitter.com/search.atom?q=sf2vigo';
$crawler = new Crawler();
167. Búsqueda en Twitter
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://search.twitter.com/search.atom?q=sf2vigo';
$crawler = new Crawler();
$content = file_get_contents($uri);
168. Búsqueda en Twitter
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://search.twitter.com/search.atom?q=sf2vigo';
$crawler = new Crawler();
$content = file_get_contents($uri);
$crawler->addXmlContent($content);
169. Búsqueda en Twitter
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://search.twitter.com/search.atom?q=sf2vigo';
$crawler = new Crawler();
$content = file_get_contents($uri);
$crawler->addXmlContent($content);
foreach($crawler->filterXpath('//content') as $node)
170. Búsqueda en Twitter
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://search.twitter.com/search.atom?q=sf2vigo';
$crawler = new Crawler();
$content = file_get_contents($uri);
$crawler->addXmlContent($content);
foreach($crawler->filterXpath('//content') as $node)
{
171. Búsqueda en Twitter
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://search.twitter.com/search.atom?q=sf2vigo';
$crawler = new Crawler();
$content = file_get_contents($uri);
$crawler->addXmlContent($content);
foreach($crawler->filterXpath('//content') as $node)
{
print $node->nodeValue;
172. Búsqueda en Twitter
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://search.twitter.com/search.atom?q=sf2vigo';
$crawler = new Crawler();
$content = file_get_contents($uri);
$crawler->addXmlContent($content);
foreach($crawler->filterXpath('//content') as $node)
{
print $node->nodeValue;
}
174. Enlaces del blog de symfony.com
use SymfonyComponentDomCrawlerCrawler;
175. Enlaces del blog de symfony.com
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://symfony.com/blog';
176. Enlaces del blog de symfony.com
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://symfony.com/blog';
$content = file_get_contents($uri);
177. Enlaces del blog de symfony.com
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://symfony.com/blog';
$content = file_get_contents($uri);
$crawler = new Crawler($content, $uri);
178. Enlaces del blog de symfony.com
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://symfony.com/blog';
$content = file_get_contents($uri);
$crawler = new Crawler($content, $uri);
$nodes = $crawler->filterXPath('//div[@class="box_article"]//a');
179. Enlaces del blog de symfony.com
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://symfony.com/blog';
$content = file_get_contents($uri);
$crawler = new Crawler($content, $uri);
$nodes = $crawler->filterXPath('//div[@class="box_article"]//a');
foreach($nodes->links() as $link)
180. Enlaces del blog de symfony.com
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://symfony.com/blog';
$content = file_get_contents($uri);
$crawler = new Crawler($content, $uri);
$nodes = $crawler->filterXPath('//div[@class="box_article"]//a');
foreach($nodes->links() as $link)
{
181. Enlaces del blog de symfony.com
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://symfony.com/blog';
$content = file_get_contents($uri);
$crawler = new Crawler($content, $uri);
$nodes = $crawler->filterXPath('//div[@class="box_article"]//a');
foreach($nodes->links() as $link)
{
print $link->getUri();
182. Enlaces del blog de symfony.com
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://symfony.com/blog';
$content = file_get_contents($uri);
$crawler = new Crawler($content, $uri);
$nodes = $crawler->filterXPath('//div[@class="box_article"]//a');
foreach($nodes->links() as $link)
{
print $link->getUri();
}
197. Enlaces del blog de symfony.com
use SymfonyComponentDomCrawlerCrawler;
198. Enlaces del blog de symfony.com
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://symfony.com/blog';
199. Enlaces del blog de symfony.com
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://symfony.com/blog';
$content = file_get_contents($uri);
200. Enlaces del blog de symfony.com
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://symfony.com/blog';
$content = file_get_contents($uri);
$crawler = new Crawler($content, $uri);
201. Enlaces del blog de symfony.com
use SymfonyComponentDomCrawlerCrawler;
$uri = 'http://symfony.com/blog';
$content = file_get_contents($uri);
$crawler = new Crawler($content, $uri);
$nodes = $crawler->filter('div.box_article a');
205. Validando que un valor sea no nulo
use SymfonyComponentValidatorConstraintsNotNull;
206. Validando que un valor sea no nulo
use SymfonyComponentValidatorConstraintsNotNull;
use SymfonyComponentValidatorConstraintsNotNullValidator;
207. Validando que un valor sea no nulo
use SymfonyComponentValidatorConstraintsNotNull;
use SymfonyComponentValidatorConstraintsNotNullValidator;
$validator = new NotNullValidator();
208. Validando que un valor sea no nulo
use SymfonyComponentValidatorConstraintsNotNull;
use SymfonyComponentValidatorConstraintsNotNullValidator;
$validator = new NotNullValidator();
if(!$validator->isValid(null, new NotNull()))
209. Validando que un valor sea no nulo
use SymfonyComponentValidatorConstraintsNotNull;
use SymfonyComponentValidatorConstraintsNotNullValidator;
$validator = new NotNullValidator();
if(!$validator->isValid(null, new NotNull()))
{
210. Validando que un valor sea no nulo
use SymfonyComponentValidatorConstraintsNotNull;
use SymfonyComponentValidatorConstraintsNotNullValidator;
$validator = new NotNullValidator();
if(!$validator->isValid(null, new NotNull()))
{
print $validator->getMessageTemplate();
211. Validando que un valor sea no nulo
use SymfonyComponentValidatorConstraintsNotNull;
use SymfonyComponentValidatorConstraintsNotNullValidator;
$validator = new NotNullValidator();
if(!$validator->isValid(null, new NotNull()))
{
print $validator->getMessageTemplate();
// "The value should not be null"
212. Validando que un valor sea no nulo
use SymfonyComponentValidatorConstraintsNotNull;
use SymfonyComponentValidatorConstraintsNotNullValidator;
$validator = new NotNullValidator();
if(!$validator->isValid(null, new NotNull()))
{
print $validator->getMessageTemplate();
// "The value should not be null"
}
213. 24 Validadores
Blank Max Date
NotBlank Min Time
Null Url DateTime
NotNull Email Locale
True IP Language
False File Country
Choice Image Collection
Type Size Callback
215. Usando la clase Validator
use SymfonyComponentValidatorValidator;
216. Usando la clase Validator
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
217. Usando la clase Validator
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingBlackholeMetadataFactory;
218. Usando la clase Validator
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingBlackholeMetadataFactory;
use SymfonyComponentValidatorConstraints as Asserts;
219. Usando la clase Validator
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingBlackholeMetadataFactory;
use SymfonyComponentValidatorConstraints as Asserts;
$validator = new Validator(
220. Usando la clase Validator
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingBlackholeMetadataFactory;
use SymfonyComponentValidatorConstraints as Asserts;
$validator = new Validator(
new BlackholeMetadataFactory,
221. Usando la clase Validator
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingBlackholeMetadataFactory;
use SymfonyComponentValidatorConstraints as Asserts;
$validator = new Validator(
new BlackholeMetadataFactory,
new ConstraintValidatorFactory
222. Usando la clase Validator
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingBlackholeMetadataFactory;
use SymfonyComponentValidatorConstraints as Asserts;
$validator = new Validator(
new BlackholeMetadataFactory,
new ConstraintValidatorFactory
);
223. Usando la clase Validator
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingBlackholeMetadataFactory;
use SymfonyComponentValidatorConstraints as Asserts;
$validator = new Validator(
new BlackholeMetadataFactory,
new ConstraintValidatorFactory
);
$errors = $validator->validateValue('', new AssertsNotBlank());
224. Usando la clase Validator
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingBlackholeMetadataFactory;
use SymfonyComponentValidatorConstraints as Asserts;
$validator = new Validator(
new BlackholeMetadataFactory,
new ConstraintValidatorFactory
);
$errors = $validator->validateValue('', new AssertsNotBlank());
if($errors->count())
225. Usando la clase Validator
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingBlackholeMetadataFactory;
use SymfonyComponentValidatorConstraints as Asserts;
$validator = new Validator(
new BlackholeMetadataFactory,
new ConstraintValidatorFactory
);
$errors = $validator->validateValue('', new AssertsNotBlank());
if($errors->count())
{
226. Usando la clase Validator
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingBlackholeMetadataFactory;
use SymfonyComponentValidatorConstraints as Asserts;
$validator = new Validator(
new BlackholeMetadataFactory,
new ConstraintValidatorFactory
);
$errors = $validator->validateValue('', new AssertsNotBlank());
if($errors->count())
{
print $errors;
227. Usando la clase Validator
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingBlackholeMetadataFactory;
use SymfonyComponentValidatorConstraints as Asserts;
$validator = new Validator(
new BlackholeMetadataFactory,
new ConstraintValidatorFactory
);
$errors = $validator->validateValue('', new AssertsNotBlank());
if($errors->count())
{
print $errors;
}
228. Usando la clase Validator
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingBlackholeMetadataFactory;
use SymfonyComponentValidatorConstraints as Asserts;
$validator = new Validator(
new BlackholeMetadataFactory,
new ConstraintValidatorFactory
);
$errors = $validator->validateValue('', new AssertsNotBlank());
if($errors->count())
{
print $errors;
}
ConstraintViolationList
230. Validando un objeto (PHP)
class Person
{
public $name;
public $age;
}
$name no puede ser una cadena vacía
$age deberán ser un número comprendido entre 18 y 99 años
233. Validando un objeto (PHP)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
234. Validando un objeto (PHP)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
235. Validando un objeto (PHP)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderStaticMethodLoader;
236. Validando un objeto (PHP)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderStaticMethodLoader;
$validator = new Validator(
237. Validando un objeto (PHP)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderStaticMethodLoader;
$validator = new Validator(
new ClassMetadataFactory(new StaticMethodLoader() ),
238. Validando un objeto (PHP)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderStaticMethodLoader;
$validator = new Validator(
new ClassMetadataFactory(new StaticMethodLoader() ),
new ConstraintValidatorFactory()
239. Validando un objeto (PHP)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderStaticMethodLoader;
$validator = new Validator(
new ClassMetadataFactory(new StaticMethodLoader() ),
new ConstraintValidatorFactory()
);
240. Validando un objeto (PHP)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderStaticMethodLoader;
$validator = new Validator(
new ClassMetadataFactory(new StaticMethodLoader() ),
new ConstraintValidatorFactory()
);
$person = new Person();
241. Validando un objeto (PHP)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderStaticMethodLoader;
$validator = new Validator(
new ClassMetadataFactory(new StaticMethodLoader() ),
new ConstraintValidatorFactory()
);
$person = new Person();
$errors = $validator->validate($person);
242. Validando un objeto (PHP)
use SymfonyComponentValidatorMappingClassMetadata;
use SymfonyComponentValidatorConstraint as Asserts;
class Person
{
public $name;
public $age;
static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata
->addPropertyConstraint('name', new AssertsNotBlank())
->addPropertyConstraint('age' , new AssertsMin(18));
->addPropertyConstraint('age' , new AssertsMax(99));
}
}
244. Validando un objeto (YAML)
class Person
{
public $name;
public $age;
}
$name no puede ser una cadena vacía
$age deberán ser un número comprendido entre 18 y 99 años
248. Validando un objeto (YAML)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
249. Validando un objeto (YAML)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
250. Validando un objeto (YAML)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderYamlFileLoader;
251. Validando un objeto (YAML)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderYamlFileLoader;
$validator = new Validator(
252. Validando un objeto (YAML)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderYamlFileLoader;
$validator = new Validator(
new ClassMetadataFactory(
253. Validando un objeto (YAML)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderYamlFileLoader;
$validator = new Validator(
new ClassMetadataFactory(
new YamlFileLoader(__DIR__.'/validate.yml')
254. Validando un objeto (YAML)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderYamlFileLoader;
$validator = new Validator(
new ClassMetadataFactory(
new YamlFileLoader(__DIR__.'/validate.yml')
),
255. Validando un objeto (YAML)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderYamlFileLoader;
$validator = new Validator(
new ClassMetadataFactory(
new YamlFileLoader(__DIR__.'/validate.yml')
),
new ConstraintValidatorFactory()
256. Validando un objeto (YAML)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderYamlFileLoader;
$validator = new Validator(
new ClassMetadataFactory(
new YamlFileLoader(__DIR__.'/validate.yml')
),
new ConstraintValidatorFactory()
);
257. Validando un objeto (YAML)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderYamlFileLoader;
$validator = new Validator(
new ClassMetadataFactory(
new YamlFileLoader(__DIR__.'/validate.yml')
),
new ConstraintValidatorFactory()
);
$person = new Person();
258. Validando un objeto (YAML)
use SymfonyComponentValidatorValidator;
use SymfonyComponentValidatorConstraintValidatorFactory;
use SymfonyComponentValidatorMappingClassMetadataFactory;
use SymfonyComponentValidatorMappingLoaderYamlFileLoader;
$validator = new Validator(
new ClassMetadataFactory(
new YamlFileLoader(__DIR__.'/validate.yml')
),
new ConstraintValidatorFactory()
);
$person = new Person();
$errors = $validator->validate($person);
270. Hola mundo ... para consolas
use SymfonyComponentConsoleApplication;
271. Hola mundo ... para consolas
use SymfonyComponentConsoleApplication;
use SymfonyComponentConsoleInputInputArgument;
272. Hola mundo ... para consolas
use SymfonyComponentConsoleApplication;
use SymfonyComponentConsoleInputInputArgument;
$console = new Application();
273. Hola mundo ... para consolas
use SymfonyComponentConsoleApplication;
use SymfonyComponentConsoleInputInputArgument;
$console = new Application();
$console
274. Hola mundo ... para consolas
use SymfonyComponentConsoleApplication;
use SymfonyComponentConsoleInputInputArgument;
$console = new Application();
$console
->register('hello')
275. Hola mundo ... para consolas
use SymfonyComponentConsoleApplication;
use SymfonyComponentConsoleInputInputArgument;
$console = new Application();
$console
->register('hello')
->setDefinition(array(
276. Hola mundo ... para consolas
use SymfonyComponentConsoleApplication;
use SymfonyComponentConsoleInputInputArgument;
$console = new Application();
$console
->register('hello')
->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
277. Hola mundo ... para consolas
use SymfonyComponentConsoleApplication;
use SymfonyComponentConsoleInputInputArgument;
$console = new Application();
$console
->register('hello')
->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
278. Hola mundo ... para consolas
use SymfonyComponentConsoleApplication;
use SymfonyComponentConsoleInputInputArgument;
$console = new Application();
$console
->register('hello')
->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
->setDescription('Saluda a una persona')
279. Hola mundo ... para consolas
use SymfonyComponentConsoleApplication;
use SymfonyComponentConsoleInputInputArgument;
$console = new Application();
$console
->register('hello')
->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
->setDescription('Saluda a una persona')
->setCode(function ($input, $output) {
280. Hola mundo ... para consolas
use SymfonyComponentConsoleApplication;
use SymfonyComponentConsoleInputInputArgument;
$console = new Application();
$console
->register('hello')
->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
->setDescription('Saluda a una persona')
->setCode(function ($input, $output) {
$name = $input->getArgument('name');
281. Hola mundo ... para consolas
use SymfonyComponentConsoleApplication;
use SymfonyComponentConsoleInputInputArgument;
$console = new Application();
$console
->register('hello')
->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
->setDescription('Saluda a una persona')
->setCode(function ($input, $output) {
$name = $input->getArgument('name');
$output->writeln(sprintf('Hola <info>%s</info>', $name));
282. Hola mundo ... para consolas
use SymfonyComponentConsoleApplication;
use SymfonyComponentConsoleInputInputArgument;
$console = new Application();
$console
->register('hello')
->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
->setDescription('Saluda a una persona')
->setCode(function ($input, $output) {
$name = $input->getArgument('name');
$output->writeln(sprintf('Hola <info>%s</info>', $name));
})
283. Hola mundo ... para consolas
use SymfonyComponentConsoleApplication;
use SymfonyComponentConsoleInputInputArgument;
$console = new Application();
$console
->register('hello')
->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
->setDescription('Saluda a una persona')
->setCode(function ($input, $output) {
$name = $input->getArgument('name');
$output->writeln(sprintf('Hola <info>%s</info>', $name));
})
;
284. Hola mundo ... para consolas
use SymfonyComponentConsoleApplication;
use SymfonyComponentConsoleInputInputArgument;
$console = new Application();
$console
->register('hello')
->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
->setDescription('Saluda a una persona')
->setCode(function ($input, $output) {
$name = $input->getArgument('name');
$output->writeln(sprintf('Hola <info>%s</info>', $name));
})
;
$console->run();
287. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
288. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
289. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
290. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
{
291. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
{
public function configure()
292. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
{
public function configure()
{
293. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
{
public function configure()
{
$this->setName('hello');
294. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
{
public function configure()
{
$this->setName('hello');
$this->setDefinition(array(
295. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
{
public function configure()
{
$this->setName('hello');
$this->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
296. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
{
public function configure()
{
$this->setName('hello');
$this->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
297. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
{
public function configure()
{
$this->setName('hello');
$this->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
$this->setDescription('Saluda a una persona')
298. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
{
public function configure()
{
$this->setName('hello');
$this->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
$this->setDescription('Saluda a una persona')
}
299. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
{
public function configure()
{
$this->setName('hello');
$this->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
$this->setDescription('Saluda a una persona')
}
public function execute($input, $output)
300. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
{
public function configure()
{
$this->setName('hello');
$this->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
$this->setDescription('Saluda a una persona')
}
public function execute($input, $output)
{
301. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
{
public function configure()
{
$this->setName('hello');
$this->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
$this->setDescription('Saluda a una persona')
}
public function execute($input, $output)
{
$name = $input->getArgument('name');
302. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
{
public function configure()
{
$this->setName('hello');
$this->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
$this->setDescription('Saluda a una persona')
}
public function execute($input, $output)
{
$name = $input->getArgument('name');
$output->writeln(sprintf('Hola <info>%s</info>', $name));
303. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
{
public function configure()
{
$this->setName('hello');
$this->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
$this->setDescription('Saluda a una persona')
}
public function execute($input, $output)
{
$name = $input->getArgument('name');
$output->writeln(sprintf('Hola <info>%s</info>', $name));
}
304. Creando un nuevo comando
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputArgument;
class HelloCommand extends Command
{
public function configure()
{
$this->setName('hello');
$this->setDefinition(array(
new InputArgument('name', InputArgument::REQUIRED, 'Nombre'),
))
$this->setDescription('Saluda a una persona')
}
public function execute($input, $output)
{
$name = $input->getArgument('name');
$output->writeln(sprintf('Hola <info>%s</info>', $name));
}
}
306. Creando un nuevo comando
use SymfonyComponentConsoleApplication;
307. Creando un nuevo comando
use SymfonyComponentConsoleApplication;
$console = new Application();
308. Creando un nuevo comando
use SymfonyComponentConsoleApplication;
$console = new Application();
$console->add(new HelloCommand());
309. Creando un nuevo comando
use SymfonyComponentConsoleApplication;
$console = new Application();
$console->add(new HelloCommand());
$console->run();
En esta primera charla del d&#xED;a me gustar&#xED;a cumplir dos objetivos\n1. Instalar y configurar el framework\n2. (M&#xE1;s importante) Entender qu&#xE9; es symfony y todo lo que lo rodea\n