SlideShare uma empresa Scribd logo
1 de 49
Baixar para ler offline
PHPMGTalks #3 – 13 de Abril de 2013
Eu! 
● Daniel Lima 
– @yourwebmaker 
– fb.com/dlpinheiro 
– Arquiteto de aplicaçÔes na 
– Produtor musical & DJ 
– Biker 
– Skater 
– Drunk 
– ...
Agenda 
● O que Ă© o Doctrine na verdade? 
– O projeto 
– Libs: 
● ORM 
● ODM: MongoDB, CouchDB 
● DBAL: Migrations 
● Common: Annotations, Cache, Data Fixtures, Inflector 
● Doctrine e outros projetos
Vamos começar!
O Projeto 
● O que Ă© o Doctrine na verdade? 
– “The Doctrine Project is the home of a selected set 
of PHP libraries primarily focused on providing 
persistence services and related functionality. Its 
prize projects are a Object Relational Mapper and 
the Database Abstraction Layer it is built on top 
of.” - http://www.doctrine-project.org/
Ou seja...
NĂŁo Ă© somente um ORM!
Colaboradores 
● Guilherme Blanco 
. Éééééé do Brasilll!!!! 
● Jonathan H. Wage 
● Benjamin Eberlei 
● Bulat Shakirzyanov 
● Fabien Potencier 
● Roman S. Borschel 
● 
.... VocĂȘ!
Agora, vamos conhecer 
algumas libraries do 
Doctrine!
ORM: Mapeador de Objeto Relacional 
● É a lib mais conhecida pela comunidade 
● Facilita o desenvolvimento voltado ao Domínio 
(problema) da aplicação 
● Aproxima o modelo entidade-relacionamento 
ao modelo Orientado a Objetos 
● NĂŁo Ă© necessĂĄrio escrever SQL 
● NĂŁo Ă© esse MONSTRO todo que pensam... 
● RTFM!!!
ORM: Mapeador de Objeto Relacional 
Passo a passo comum: 
– Crie suas tabelas 
– Crie suas classes 
– Mapeie suas classes 
– Instancie suas classes 
– Salve seus objetos 
– Traga seus objetos salvos
Crie suas tabelas no banco de dados
Crie suas classes
Crie suas classes
Mapeie suas classes 
● Classe “Usuario” mapeada 
– https://gist.github.com/yourwebmaker/5369280#fil 
e-usuario-php 
● Classe “Grupo” mapeada 
– https://gist.github.com/yourwebmaker/5369280#fil 
e-grupo-php
Instancie suas classes
Instancie suas classes 
Salve seus objetos
Traga seus objetos salvos
ODM: Mapeador para No-SQL 
● Mesmo “Conceito” do ORM, mas trabalha 
somente com bancos No-Sql 
● Oferece funcionalidades extras que os Clients 
No-Sql nĂŁo oferecem: 
– Event Manager 
– EntityRepositories 
– Herança 
● MongoDB, CouchDB, OrientDB... 
● O projeto DoctrineKeyValueStore pretende 
padronizar o uso de bancos No-Sql.
DBAL: Data Base Abstraction & Access 
Layer 
● Camada de abstração de banco de dados 
sobre a PDO 
● Oferece funcionalidades extras à PDO 
● ORM faz uso da DBAL
DBAL: Alguns Recursos extras Ă  PDO 
● Cache
DBAL: Alguns Recursos extras Ă  PDO 
● Eventos
DBAL: Alguns Recursos extras Ă  PDO 
● Tipos 
– CREATE DOMAIN MyMoney AS DECIMAL(18,3); 
– Definindo um tipo: 
https://gist.github.com/yourwebmaker/7a61f175c7 
59cf00096d#file-moneytype-php 
– Adicionando um tipo:
DBAL: Alguns Recursos extras Ă  PDO 
● Schema-Manager
DBAL: Alguns Recursos extras Ă  PDO 
● Schema-Representation
DBAL: Alguns Recursos extras Ă  PDO 
● Schema-Representation
DBAL: Alguns Recursos extras Ă  PDO 
● Query Builder
CommonAnnotations 
● /** 
* @var 
* @todo 
* @Entity(repositoryClass=”XRepository”) 
* @ORMEntity 
* @AssertNotBlank() 
*/ 
● "Annotations provide data about a program that is 
not part of the program itself. They have no direct 
effect on the operation of the code they 
annotate." Oracle 
● São como arquivos de configuração
CommonAnnotations
CommonCache 
● ApcCache (requires ext/apc) 
● ArrayCache (in memory, lifetime of the request) 
● FilesystemCache (not optimal for high concurrency) 
● MemcacheCache (requires ext/memcache) 
● MemcachedCache (requires ext/memcached) 
● PhpFileCache (not optimal for high concurrency) 
● RedisCache.php (requires ext/phpredis) 
● WinCacheCache.php (requires ext/wincache) 
● XcacheCache.php (requires ext/xcache) 
● ZendDataCache.php (requires Zend Server Platform)
CommonCache
CommonDataFixtures
CommonDataFixtures
CommonInflector
DBALMigrations 
● “The Doctrine Migrations offer additional 
functionality on top of the database abstraction 
layer (DBAL) for versioning your database 
schema and easily deploying changes to it. It 
is a very easy to use and powerful tool.” 
● Instale na munheca... ou... use o PHAR! 
● 1000000x.... USE O PHAR!
DBALMigrations
DBALMigrations 
● Configuração 
– table_name: doctrine_migration_versions 
migrations_directory: 
/path/to/migrations/classes/DoctrineMigrations 
migrations: 
migration1: 
version: 20100704000000 
class: DoctrineMigrationsNewMigration
DBALMigrations 
● $ doctrine-migrations:generate 
Generated new migration class to 
"/path/to/migrations/classes/DoctrineMigrations/Ve 
rsion20100416130422.php"
DBALMigrations
DBALMigrations
DBALMigrations 
$ ./doctrine migrations:status 
== Configuration 
>> Name: Doctrine Sandbox Migrations 
>> Database Driver: pdo_mysql 
>> Database Name: testdb 
>> Configuration Source: 
/Users/jwage/Sites/doctrine2git/tools/sandbox/migrations.xml 
>> Version Table Name: doctrine_migration_versions 
>> Migrations Namespace: DoctrineMigrations 
>> Migrations Directory: 
/Users/jwage/Sites/doctrine2git/tools/sandbox/DoctrineMigrations 
>> Current Version: 2010-04-16 13:04:22 
(20100416130422) 
>> Latest Version: 2010-04-16 13:04:22 
(20100416130422) 
>> Executed Migrations: 0 
>> Available Migrations: 1 
>> New Migrations: 1 
== Migration Versions 
>> 2010-04-16 13:04:01 (20100416130401) not migrated
DBALMigrations 
$ ./doctrine migrations:migrate --dry-run 
Are you sure you wish to continue? 
y 
Executing dry run of migration up to 20100416130452 
from 0 
>> migrating 20100416130452 
-> CREATE TABLE users (username VARCHAR(255) NOT 
NULL, password VARCHAR(255) NOT NULL) ENGINE = InnoDB
DBALMigrations 
$ ./doctrine migrations:migrate 0 
Are you sure you wish to continue? 
y 
Migrating down to 0 from 20100416130422 
-- reverting 20100416130422 
-> DROP TABLE addresses 
-- reverted 
-- reverting 20100416130401 
-> DROP TABLE users 
-- reverted
Doctrine e outros projetos 
● Symfony 
– Validators 
– Router 
● Zend Framework 2 
● Zend Framework 1 
● JSMSerializer 
● DMSFilter 
● SuaSempresaSuaLib
Como obter ajuda? 
● Google Groups: 
– Doctrine-user 
– Doctrine-dev 
– Doctrine-BR 
● IRC 
– irc.freenode.net/doctrine 
– irc.freenode.net/doctrine-dev 
– irc.freenode.net/doctrine-mongodb-odm 
● LEIA O MANUAL DE CABO A RABO!
Contribuindo com o Doctrine 
● http://www.doctrine-project.org/contribute.html 
● https://github.com/doctrine 
– Há sempre projetos interessantes lá =)
ReflexÔes...
Perguntas?
Obrigado!

Mais conteĂșdo relacionado

Mais procurados

Tips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development EfficiencyTips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development EfficiencyOlivier Bourgeois
 
Gdb basics for my sql db as (openfest 2017) final
Gdb basics for my sql db as (openfest 2017) finalGdb basics for my sql db as (openfest 2017) final
Gdb basics for my sql db as (openfest 2017) finalValeriy Kravchuk
 
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginxLSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginxMarian Marinov
 
drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010Florian Latzel
 
Drupal 6.x, Drupal 7.x -- Scratching the surface
Drupal 6.x, Drupal 7.x -- Scratching the surfaceDrupal 6.x, Drupal 7.x -- Scratching the surface
Drupal 6.x, Drupal 7.x -- Scratching the surfaceFlorian Latzel
 
CouchDB in The Room
CouchDB in The RoomCouchDB in The Room
CouchDB in The RoomMakoto Ohnami
 
Drush und Multisite: drush_multi
Drush und Multisite: drush_multiDrush und Multisite: drush_multi
Drush und Multisite: drush_multiFlorian Latzel
 
Apache Dispatch
Apache DispatchApache Dispatch
Apache DispatchFred Moyer
 
Session 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise JavaSession 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise JavaPawanMM
 
PERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schemaPERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schemaFromDual GmbH
 
Active Data Stores at 30,000ft
Active Data Stores at 30,000ftActive Data Stores at 30,000ft
Active Data Stores at 30,000ftJeffrey Sica
 
Perl Stored Procedures for MySQL (2009)
Perl Stored Procedures for MySQL (2009)Perl Stored Procedures for MySQL (2009)
Perl Stored Procedures for MySQL (2009)Antony T Curtis
 

Mais procurados (18)

Node.js an Exectutive View
Node.js an Exectutive ViewNode.js an Exectutive View
Node.js an Exectutive View
 
Tips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development EfficiencyTips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development Efficiency
 
Couch Db
Couch DbCouch Db
Couch Db
 
Gdb basics for my sql db as (openfest 2017) final
Gdb basics for my sql db as (openfest 2017) finalGdb basics for my sql db as (openfest 2017) final
Gdb basics for my sql db as (openfest 2017) final
 
rubyonrails
rubyonrailsrubyonrails
rubyonrails
 
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginxLSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
 
drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010
 
Drupal 6.x, Drupal 7.x -- Scratching the surface
Drupal 6.x, Drupal 7.x -- Scratching the surfaceDrupal 6.x, Drupal 7.x -- Scratching the surface
Drupal 6.x, Drupal 7.x -- Scratching the surface
 
CouchDB in The Room
CouchDB in The RoomCouchDB in The Room
CouchDB in The Room
 
Drush und Multisite: drush_multi
Drush und Multisite: drush_multiDrush und Multisite: drush_multi
Drush und Multisite: drush_multi
 
Apache Dispatch
Apache DispatchApache Dispatch
Apache Dispatch
 
Session 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise JavaSession 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise Java
 
sysprog4
sysprog4sysprog4
sysprog4
 
PERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schemaPERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schema
 
Java 2
Java 2Java 2
Java 2
 
Active Data Stores at 30,000ft
Active Data Stores at 30,000ftActive Data Stores at 30,000ft
Active Data Stores at 30,000ft
 
Perl Stored Procedures for MySQL (2009)
Perl Stored Procedures for MySQL (2009)Perl Stored Procedures for MySQL (2009)
Perl Stored Procedures for MySQL (2009)
 
netbeans
netbeansnetbeans
netbeans
 

Semelhante a Doctrine Project

Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP appsMatteo Moretti
 
Scaling symfony apps
Scaling symfony appsScaling symfony apps
Scaling symfony appsMatteo Moretti
 
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfHashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfssuser705051
 
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Per Henrik Lausten
 
Scaling up and accelerating Drupal 8 with NoSQL
Scaling up and accelerating Drupal 8 with NoSQLScaling up and accelerating Drupal 8 with NoSQL
Scaling up and accelerating Drupal 8 with NoSQLOSInet
 
Drupal and the semantic web - SemTechBiz 2012
Drupal and the semantic web - SemTechBiz 2012Drupal and the semantic web - SemTechBiz 2012
Drupal and the semantic web - SemTechBiz 2012scorlosquet
 
Drupal 7 and RDF
Drupal 7 and RDFDrupal 7 and RDF
Drupal 7 and RDFscorlosquet
 
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?Wong Hoi Sing Edison
 
MongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL DatabaseMongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL DatabaseFITC
 
Plain english guide to drupal 8 criticals
Plain english guide to drupal 8 criticalsPlain english guide to drupal 8 criticals
Plain english guide to drupal 8 criticalsAngela Byron
 
Drupal as a Semantic Web platform - ISWC 2012
Drupal as a Semantic Web platform - ISWC 2012Drupal as a Semantic Web platform - ISWC 2012
Drupal as a Semantic Web platform - ISWC 2012scorlosquet
 
Drupal training-1-in-mumbai
Drupal training-1-in-mumbaiDrupal training-1-in-mumbai
Drupal training-1-in-mumbaivibrantuser
 
Drupal 8 improvements for developer productivity php symfony and more
Drupal 8 improvements for developer productivity  php symfony and moreDrupal 8 improvements for developer productivity  php symfony and more
Drupal 8 improvements for developer productivity php symfony and moreAcquia
 
Ubuntu scope development
Ubuntu scope developmentUbuntu scope development
Ubuntu scope developmentXiaoguo Liu
 
Docker introduction
Docker introductionDocker introduction
Docker introductionMarcelo Ochoa
 
Customize and Secure the Runtime and Dependencies of Your Procedural Language...
Customize and Secure the Runtime and Dependencies of Your Procedural Language...Customize and Secure the Runtime and Dependencies of Your Procedural Language...
Customize and Secure the Runtime and Dependencies of Your Procedural Language...VMware Tanzu
 

Semelhante a Doctrine Project (20)

Zend Framework MVC driven ExtJS
Zend Framework MVC driven ExtJSZend Framework MVC driven ExtJS
Zend Framework MVC driven ExtJS
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
Scaling symfony apps
Scaling symfony appsScaling symfony apps
Scaling symfony apps
 
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfHashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
 
Terraform-2.pdf
Terraform-2.pdfTerraform-2.pdf
Terraform-2.pdf
 
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)
 
Scaling up and accelerating Drupal 8 with NoSQL
Scaling up and accelerating Drupal 8 with NoSQLScaling up and accelerating Drupal 8 with NoSQL
Scaling up and accelerating Drupal 8 with NoSQL
 
Drupal and the semantic web - SemTechBiz 2012
Drupal and the semantic web - SemTechBiz 2012Drupal and the semantic web - SemTechBiz 2012
Drupal and the semantic web - SemTechBiz 2012
 
Drupal 7 and RDF
Drupal 7 and RDFDrupal 7 and RDF
Drupal 7 and RDF
 
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
 
MongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL DatabaseMongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL Database
 
Plain english guide to drupal 8 criticals
Plain english guide to drupal 8 criticalsPlain english guide to drupal 8 criticals
Plain english guide to drupal 8 criticals
 
Drupal as a Semantic Web platform - ISWC 2012
Drupal as a Semantic Web platform - ISWC 2012Drupal as a Semantic Web platform - ISWC 2012
Drupal as a Semantic Web platform - ISWC 2012
 
New paradigms
New paradigmsNew paradigms
New paradigms
 
Drupal training-1-in-mumbai
Drupal training-1-in-mumbaiDrupal training-1-in-mumbai
Drupal training-1-in-mumbai
 
Drupal 8 improvements for developer productivity php symfony and more
Drupal 8 improvements for developer productivity  php symfony and moreDrupal 8 improvements for developer productivity  php symfony and more
Drupal 8 improvements for developer productivity php symfony and more
 
Ubuntu scope development
Ubuntu scope developmentUbuntu scope development
Ubuntu scope development
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Customize and Secure the Runtime and Dependencies of Your Procedural Language...
Customize and Secure the Runtime and Dependencies of Your Procedural Language...Customize and Secure the Runtime and Dependencies of Your Procedural Language...
Customize and Secure the Runtime and Dependencies of Your Procedural Language...
 
Goodpractice
GoodpracticeGoodpractice
Goodpractice
 

Último

Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïž
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïžcall girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïž
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïžDelhi Call girls
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationShrmpro
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durbanmasabamasaba
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp KrisztiĂĄn
 
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïž
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïžcall girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïž
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïžDelhi Call girls
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 

Último (20)

Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïž
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïžcall girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïž
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïž
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïž
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïžcall girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïž
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïž
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 

Doctrine Project

  • 1. PHPMGTalks #3 – 13 de Abril de 2013
  • 2. Eu! ● Daniel Lima – @yourwebmaker – fb.com/dlpinheiro – Arquiteto de aplicaçÔes na – Produtor musical & DJ – Biker – Skater – Drunk – ...
  • 3. Agenda ● O que Ă© o Doctrine na verdade? – O projeto – Libs: ● ORM ● ODM: MongoDB, CouchDB ● DBAL: Migrations ● Common: Annotations, Cache, Data Fixtures, Inflector ● Doctrine e outros projetos
  • 5. O Projeto ● O que Ă© o Doctrine na verdade? – “The Doctrine Project is the home of a selected set of PHP libraries primarily focused on providing persistence services and related functionality. Its prize projects are a Object Relational Mapper and the Database Abstraction Layer it is built on top of.” - http://www.doctrine-project.org/
  • 8. Colaboradores ● Guilherme Blanco 
. Éééééé do Brasilll!!!! ● Jonathan H. Wage ● Benjamin Eberlei ● Bulat Shakirzyanov ● Fabien Potencier ● Roman S. Borschel ● 
.... VocĂȘ!
  • 9. Agora, vamos conhecer algumas libraries do Doctrine!
  • 10. ORM: Mapeador de Objeto Relacional ● É a lib mais conhecida pela comunidade ● Facilita o desenvolvimento voltado ao DomĂ­nio (problema) da aplicação ● Aproxima o modelo entidade-relacionamento ao modelo Orientado a Objetos ● NĂŁo Ă© necessĂĄrio escrever SQL ● NĂŁo Ă© esse MONSTRO todo que pensam... ● RTFM!!!
  • 11. ORM: Mapeador de Objeto Relacional Passo a passo comum: – Crie suas tabelas – Crie suas classes – Mapeie suas classes – Instancie suas classes – Salve seus objetos – Traga seus objetos salvos
  • 12. Crie suas tabelas no banco de dados
  • 15. Mapeie suas classes ● Classe “Usuario” mapeada – https://gist.github.com/yourwebmaker/5369280#fil e-usuario-php ● Classe “Grupo” mapeada – https://gist.github.com/yourwebmaker/5369280#fil e-grupo-php
  • 17. Instancie suas classes Salve seus objetos
  • 19. ODM: Mapeador para No-SQL ● Mesmo “Conceito” do ORM, mas trabalha somente com bancos No-Sql ● Oferece funcionalidades extras que os Clients No-Sql nĂŁo oferecem: – Event Manager – EntityRepositories – Herança ● MongoDB, CouchDB, OrientDB... ● O projeto DoctrineKeyValueStore pretende padronizar o uso de bancos No-Sql.
  • 20. DBAL: Data Base Abstraction & Access Layer ● Camada de abstração de banco de dados sobre a PDO ● Oferece funcionalidades extras Ă  PDO ● ORM faz uso da DBAL
  • 21. DBAL: Alguns Recursos extras Ă  PDO ● Cache
  • 22. DBAL: Alguns Recursos extras Ă  PDO ● Eventos
  • 23. DBAL: Alguns Recursos extras Ă  PDO ● Tipos – CREATE DOMAIN MyMoney AS DECIMAL(18,3); – Definindo um tipo: https://gist.github.com/yourwebmaker/7a61f175c7 59cf00096d#file-moneytype-php – Adicionando um tipo:
  • 24. DBAL: Alguns Recursos extras Ă  PDO ● Schema-Manager
  • 25. DBAL: Alguns Recursos extras Ă  PDO ● Schema-Representation
  • 26. DBAL: Alguns Recursos extras Ă  PDO ● Schema-Representation
  • 27. DBAL: Alguns Recursos extras Ă  PDO ● Query Builder
  • 28. CommonAnnotations ● /** * @var * @todo * @Entity(repositoryClass=”XRepository”) * @ORMEntity * @AssertNotBlank() */ ● "Annotations provide data about a program that is not part of the program itself. They have no direct effect on the operation of the code they annotate." Oracle ● SĂŁo como arquivos de configuração
  • 30. CommonCache ● ApcCache (requires ext/apc) ● ArrayCache (in memory, lifetime of the request) ● FilesystemCache (not optimal for high concurrency) ● MemcacheCache (requires ext/memcache) ● MemcachedCache (requires ext/memcached) ● PhpFileCache (not optimal for high concurrency) ● RedisCache.php (requires ext/phpredis) ● WinCacheCache.php (requires ext/wincache) ● XcacheCache.php (requires ext/xcache) ● ZendDataCache.php (requires Zend Server Platform)
  • 35. DBALMigrations ● “The Doctrine Migrations offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes to it. It is a very easy to use and powerful tool.” ● Instale na munheca... ou... use o PHAR! ● 1000000x.... USE O PHAR!
  • 37. DBALMigrations ● Configuração – table_name: doctrine_migration_versions migrations_directory: /path/to/migrations/classes/DoctrineMigrations migrations: migration1: version: 20100704000000 class: DoctrineMigrationsNewMigration
  • 38. DBALMigrations ● $ doctrine-migrations:generate Generated new migration class to "/path/to/migrations/classes/DoctrineMigrations/Ve rsion20100416130422.php"
  • 41. DBALMigrations $ ./doctrine migrations:status == Configuration >> Name: Doctrine Sandbox Migrations >> Database Driver: pdo_mysql >> Database Name: testdb >> Configuration Source: /Users/jwage/Sites/doctrine2git/tools/sandbox/migrations.xml >> Version Table Name: doctrine_migration_versions >> Migrations Namespace: DoctrineMigrations >> Migrations Directory: /Users/jwage/Sites/doctrine2git/tools/sandbox/DoctrineMigrations >> Current Version: 2010-04-16 13:04:22 (20100416130422) >> Latest Version: 2010-04-16 13:04:22 (20100416130422) >> Executed Migrations: 0 >> Available Migrations: 1 >> New Migrations: 1 == Migration Versions >> 2010-04-16 13:04:01 (20100416130401) not migrated
  • 42. DBALMigrations $ ./doctrine migrations:migrate --dry-run Are you sure you wish to continue? y Executing dry run of migration up to 20100416130452 from 0 >> migrating 20100416130452 -> CREATE TABLE users (username VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL) ENGINE = InnoDB
  • 43. DBALMigrations $ ./doctrine migrations:migrate 0 Are you sure you wish to continue? y Migrating down to 0 from 20100416130422 -- reverting 20100416130422 -> DROP TABLE addresses -- reverted -- reverting 20100416130401 -> DROP TABLE users -- reverted
  • 44. Doctrine e outros projetos ● Symfony – Validators – Router ● Zend Framework 2 ● Zend Framework 1 ● JSMSerializer ● DMSFilter ● SuaSempresaSuaLib
  • 45. Como obter ajuda? ● Google Groups: – Doctrine-user – Doctrine-dev – Doctrine-BR ● IRC – irc.freenode.net/doctrine – irc.freenode.net/doctrine-dev – irc.freenode.net/doctrine-mongodb-odm ● LEIA O MANUAL DE CABO A RABO!
  • 46. Contribuindo com o Doctrine ● http://www.doctrine-project.org/contribute.html ● https://github.com/doctrine – HĂĄ sempre projetos interessantes lĂĄ =)