Upload
er-galvao-abbott
View
275
Download
1
Embed Size (px)
DESCRIPTION
Uma apresentação mezzo básica, mezzo intermediária sobre o Zend Framework 2, um dos frameworks mais robustos e populares para a linguagem PHP.
Citation preview
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 1 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
Desenvolvendo Aplicações com
2
Er Galvão Abbott é Presidente da ABRAPHP – Associação Brasileira de Profissionais PHP e Diretor da PHP Conference Brasil, o principal evento de PHP da América Latina.
Trabalha há 20 anos desenvolvendo sistemas e aplicações com interface web, sendo 15 destes com PHP e 7 com Zend Framework. Trabalhou com diversas empresas de grande porte, tanto nacionais como internacionais.
Palestra em eventos, ministra cursos presenciais e a distânciae é o fundador e líder do GU PHPBR, Grupo de Usuários de abrangência nacional, que hoje conta com mais de 1.200usuários cadastrados.
Site: http://www.galvao.eti.br/Twitter: @galvaoSlides e Documentos: http://slideshare.net/ergalvao https://speakerdeck.com/galvaoGithub: http://github.com/galvao
Quem?!
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 2 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
Objetivo
Apresentar detalhes Básicos → Intermediários sobre o Zend Framework 2, detalhando conceitos envolvidos no desenvolvimento de uma aplicação.
Serão apresentados os seguintes tópicos:
→ Porque escolher o ZF2?→ Setup inicial, “Instalação” e Configuração→ Ambientes→ Rotas→ Models, Controllers e Views→ Validação→ CRUD
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 3 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
Por quê ZF2?
Open Source PHP >= 5.3> 2 anos e meio namespaces> 2.000 changesets closures> 200 profissionais late static bindingMicrosoft, Google, et al.
Composer GithubPHAR PHPUnit100% OO TravisCIS.O.L.I.D.
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 4 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
Por quê ZF2?
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 5 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
Modular
modules.zendframework.com
Flexível
Dependency Injection,
application.config.php,Module.php,module.config.php
Eventos
Serviços
Skeleton Application – Instalação
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 6 / 34
github.com/zendframework/ZendSkeletonApplication
Composer git clone git submodule download
composer create-project -sdev --repository-url="https://packages.zendframework.com" zendframework/skeleton-application path/to/install
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 7 / 34
Skeleton Application – Estrutura
Configuração a nível de aplicação
Dados da aplicação
Módulos da aplicação
Raiz web
Componentes/Módulos externos
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 8 / 34
Configuração a nível de aplicação
Configuração do “ambiente”
Configuração “global” da Aplicação
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
Skeleton Application – Estrutura
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 9 / 34
Configuração do Módulo
Raiz do Módulo
i18n
Fonte do Módulo
Inicialização do Módulo
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
Skeleton Application – Estrutura
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 10 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
Skeleton Application – Estrutura
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 11 / 34
Zend Framework 2
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
Skeleton Application – Estrutura
MVC – ZF2 Style
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 12 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
Requisição
Inicializaçãodo Módulo
Bootstrap
Resposta
Execução daAplicação
Roteamento Dispatch
Setup inicial
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 13 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
public/index.php
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 14 / 34
Setup inicial
config/autoload/global.php
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 15 / 34
Setup inicial
config/autoload/local.php
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 16 / 34
Setup inicial
module/Application/Module.php
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
Setup inicial
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 17 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
config/application.config.php
module/Application/config/module.config.php … ?!?!
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 18 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
module/Application/config/module.config.php … ?!?!
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 19 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
Muita calma nessa hora!
Ufa!
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 20 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
module/Application/config/module.config.php
Rotas
Serviços
Controllers “disponíveis”
Questões sobre a camada de view
Rotas
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 21 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
Literais
Rotas
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 22 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
Com rotas filhas / com segmentos (≃ ZF1)
Controllers
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 23 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
module/Application/src/Application/Controller/IndexController.php
Dados Externos: Forms
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 24 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
module/Application/src/Application/Form/User/Register.php
Dados Externos: Filtros
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 25 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
module/Application/src/Application/Filter/User/Register.php
Models
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 26 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
module/Application/src/Application/Model/User.php
Models
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 27 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
module/Application/src/Application/Model/UserTable.php
Models
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 28 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
module/Application/src/Application/Module.php
Models - CRUD
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 29 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
module/Application/src/Application/Model/UserTable.php
Models - CRUD
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 30 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
module/Application/src/Application/Model/UserTable.php
Models - CRUD
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 31 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
module/Application/src/Application/Model/UserTable.php
Unindo as partes na Controller
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 32 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
module/Application/src/Application/Controller/UserController.php
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 33 / 34
Concluindo...
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br
Obrigado!
? Dúvidas?↓ Críticas?↑ Elogios?!
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 9/27/14 - 34 / 34
Desenvolvendo Aplicações com ZF2 www.galvao.eti.br