O documento resume Fabien Potencier, criador do framework Symfony. Ele descreve sua biografia, trabalho na Sensio e como criou o Symfony. Também explica brevemente o que é o Symfony2, seus principais componentes e como iniciar um projeto com ele.
8. Sobre o criador ... Fabien Potencier @fabpot Paris, France Sensio CEO (sensiolabs.com) and Symfony lead developer (symfony.com) http://fabien.potencier.org Work CEO at Sensio About Fabien discovered the Web in 1994, at a time when connecting to the Internet was still associated with the harmful strident sounds of a modem. Being a developer by passion, he immediately started to build websites with Perl. But with the release of PHP 5, he decided to switch focus to PHP, and created the symfony framework project in 2004 to help his company leverage the power of PHP for its customers. Fabien is a serial-entrepreneur, and among other companies, he created Sensio, a services and consulting company specialized in web technologies and Internet marketing, in 1998. Fabien is also the creator of several other Open-Source projects, a writer, a blogger, a speaker at internatio
19. Oficialização do Symfony2... “ After 12 preview releases, 5 beta versions, and 6 release candidates, I'm very orgulhoso to announce the immediate availability of Symfony 2.0, final version. Since the first preview release, published 18 months ago during the Symfony Live conference, the Symfony community has done an amazing work. The Symfony2 code quality would not have been the same without their outstanding work. Thank you!” Symfony 2.0 (http://symfony.com/blog/symfony-2-0) by Fabien Potencier – July 28, 2011
20.
21. “Since March 2011, more than 100 new contributors have joined the Symfony2 team (250 vs 150); and more than 250 new bundles have been created on Github (440 vs 170)” Symfony 2.0 (http://symfony.com/blog/symfony-2-0) by Fabien Potencier – July 28, 2011
22.
23. “Then, based on these components, Symfony2 is also a full-stack web framework”
24. “ Dependendo do seu projeto e de suas necessidades, você pode escolher alguns dos componentes do Symfony2 e iniciar o projeto com eles, ou você pode usar tudo do framework e se beneficiar com a integração que ele proporciona” Fabien Potencier – publicado em seu blog pessoal (25/10/11)
25.
26.
27. “ Symfony2 is a great framework for bigger projects where tens of developers are involved and where the business logic is more complex. And the Symfony2 components are for people who don't want to use a framework, or for other Open-Source projects that don't want to reinvent the wheel ” Fabien Potencier – publicado em seu blog pessoal (25/10/11)
49. “ Distributions : A distribution is a pre-configured Symfony2 project with a selection of bundles and sensible defaults. The Symfony Standard Edition also comes with a Web configurator. That makes the installation and configuration of a new Symfony2 project fast and insanely easy”
50. “ Everything is a Bundle in Symfony2 : A bundle is a directory containing a set of files (PHP files, stylesheets, JavaScripts, images, ...) that implement a single feature (a blog, a forum, etc). That changes everything. Share your bundles between your projects or publish them in the wild”
51. “ Symfony2 is Fast : the raw performance of the framework is great, but there is more”
80. Exemplo de um bundle criado automaticamente: Ifpi/Bundles/DisciplinasBundle Estrutura de diretórios IfpiBundlesDisciplinasBundle: resource: "@IfpiBundlesDisciplinasBundle/Controller/" type: annotation prefix: / Rota criada em /app/config/routing.yml public function registerBundles() {.... new IfpiundlesisciplinasBundlefpiBundlesDisciplinasBundle(), ); Bundle registrado no app/appKernel.php
111. Tipos de validação Basic Constraints These are the basic comstraints: use them to assert very basic things about the value of properties or the return value of methods on your object. NotBlank Blank NotNull Null True False Type String Constraints Email MinLength MaxLength Url Regex Ip Number Constraints Max Min Date Constraints Date DateTime Time Collection Constraints Choice Collection UniqueEntity Language Locale Country File Constraints File Image
112. Algumas validações // src/Ifpi/Bundle/DisciplinasBundle/Aluno.php use Symfonyomponentalidatoronstraints as Assert; class Aluno { /** * @AssertotBlank(); * @Assertax(limit = 10, message = "O valor para média não pode ultrapassar o limite de DEZ.") * @Assertin(limit = 0, message = "O valor para média não pode ser inferior que ZERO.") */ private $media; } Valor Máximo e Mínimo de um atributo @Assertmail( * message = "The email '{{ value }}' is not a valid email.", * checkMX = true * ) protected $email; Validação de e-mail para um atributo /** * @Assertate() */ protected $dataNasc; Validação de data /** * @Asserthoice(choices = {"masculino", "feminino"}, message = "Escolha um sexo válido.") */ protected $sexo; Validação de opções Importação comum em todos os exemplos abaixo
113. Validação usando um callback // src/Acme/BlogBundle/Entity/Author.php use Symfonyomponentalidatoronstraints as Assert; use SymfonyomponentalidatorxecutionContext; /** * @Assertallback(methods={"isAuthorValid"}) */ class Author { // ... private $firstName; public function isAuthorValid(ExecutionContext $context) { // somehow you have an array of "fake names" $fakeNames = array(); // check if the name is actually a fake name if (in_array($this->getFirstName(), $fakeNames)) { $property_path = $context->getPropertyPath() . '.firstName'; $context->setPropertyPath($property_path); $context->addViolation('This name sounds totally fake!', array(), null); } } } Setup Método
128. Crie regras de validação para os campos: vTelefone, vRaca, bPedigree e vCor; Faça também com que o campo tHora aceite apenas o intervalo entre 08:00 e 18:00 horas.