SlideShare a Scribd company logo
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!

More Related Content

PDF
Gdb basics for my sql db as (percona live europe 2019)
PPTX
(Open Hack Night Fall 2014) Hacking Tutorial
PDF
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
PDF
Migrating data to drupal 8
PDF
Using LuaJIT in mid-load web-projects
PDF
Doctrine Php Object Relational Mapper
PDF
Node.js Course 1 of 2 - Introduction and first steps
PDF
Node.js Course 2 of 2 - Advanced techniques
Gdb basics for my sql db as (percona live europe 2019)
(Open Hack Night Fall 2014) Hacking Tutorial
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
Migrating data to drupal 8
Using LuaJIT in mid-load web-projects
Doctrine Php Object Relational Mapper
Node.js Course 1 of 2 - Introduction and first steps
Node.js Course 2 of 2 - Advanced techniques

What's hot (18)

PDF
Node.js an Exectutive View
PDF
Tips and Tricks for Increased Development Efficiency
PDF
Couch Db
PDF
Gdb basics for my sql db as (openfest 2017) final
PDF
rubyonrails
ODP
LSA2 - 03 Http apache nginx
PDF
drush_multi @ DrupalDevDays 2010
PDF
Drupal 6.x, Drupal 7.x -- Scratching the surface
PDF
CouchDB in The Room
PDF
Drush und Multisite: drush_multi
PDF
Apache Dispatch
PPTX
Session 24 - JDBC, Intro to Enterprise Java
PDF
sysprog4
PDF
PERFORMANCE_SCHEMA and sys schema
PPTX
PPTX
Active Data Stores at 30,000ft
PDF
Perl Stored Procedures for MySQL (2009)
PDF
netbeans
Node.js an Exectutive View
Tips and Tricks for Increased Development Efficiency
Couch Db
Gdb basics for my sql db as (openfest 2017) final
rubyonrails
LSA2 - 03 Http apache nginx
drush_multi @ DrupalDevDays 2010
Drupal 6.x, Drupal 7.x -- Scratching the surface
CouchDB in The Room
Drush und Multisite: drush_multi
Apache Dispatch
Session 24 - JDBC, Intro to Enterprise Java
sysprog4
PERFORMANCE_SCHEMA and sys schema
Active Data Stores at 30,000ft
Perl Stored Procedures for MySQL (2009)
netbeans
Ad

Similar to Doctrine Project (20)

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

Recently uploaded (20)

PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
top salesforce developer skills in 2025.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
System and Network Administraation Chapter 3
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
history of c programming in notes for students .pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Introduction to Artificial Intelligence
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Odoo POS Development Services by CandidRoot Solutions
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
top salesforce developer skills in 2025.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
2025 Textile ERP Trends: SAP, Odoo & Oracle
System and Network Administraation Chapter 3
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
history of c programming in notes for students .pptx
CHAPTER 2 - PM Management and IT Context
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Upgrade and Innovation Strategies for SAP ERP Customers
VVF-Customer-Presentation2025-Ver1.9.pptx
Wondershare Filmora 15 Crack With Activation Key [2025
Understanding Forklifts - TECH EHS Solution
Softaken Excel to vCard Converter Software.pdf
Introduction to Artificial Intelligence
Odoo Companies in India – Driving Business Transformation.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Odoo POS Development Services by CandidRoot Solutions

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ĂĄ =)