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
 
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

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
 
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

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
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
 
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
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%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
 
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
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
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
 

Último (20)

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
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
 
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
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%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
 
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
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
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...
 

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/
  • 7. Não é somente um ORM!
  • 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á =)