Desenvolvendo aplicações com ZF2
-
Upload
er-galvao-abbott -
Category
Technology
-
view
275 -
download
1
description
Transcript of Desenvolvendo aplicações com ZF2
![Page 1: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/1.jpg)
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
![Page 2: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/2.jpg)
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
![Page 3: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/3.jpg)
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
![Page 4: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/4.jpg)
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
![Page 5: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/5.jpg)
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
![Page 6: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/6.jpg)
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
![Page 7: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/7.jpg)
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
![Page 8: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/8.jpg)
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
![Page 9: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/9.jpg)
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
![Page 10: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/10.jpg)
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
![Page 11: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/11.jpg)
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
![Page 12: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/12.jpg)
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
![Page 13: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/13.jpg)
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
![Page 14: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/14.jpg)
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
![Page 15: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/15.jpg)
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
![Page 16: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/16.jpg)
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
![Page 17: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/17.jpg)
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
![Page 18: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/18.jpg)
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
![Page 19: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/19.jpg)
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!
![Page 20: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/20.jpg)
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
![Page 21: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/21.jpg)
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
![Page 22: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/22.jpg)
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)
![Page 23: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/23.jpg)
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
![Page 24: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/24.jpg)
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
![Page 25: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/25.jpg)
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
![Page 26: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/26.jpg)
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
![Page 27: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/27.jpg)
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
![Page 28: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/28.jpg)
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
![Page 29: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/29.jpg)
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
![Page 30: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/30.jpg)
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
![Page 31: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/31.jpg)
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
![Page 32: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/32.jpg)
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
![Page 33: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/33.jpg)
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
![Page 34: Desenvolvendo aplicações com ZF2](https://reader034.fdocuments.net/reader034/viewer/2022051013/547e873bb4795998508b4b93/html5/thumbnails/34.jpg)
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