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

What's hot

Node.js an Exectutive View
Node.js an Exectutive ViewNode.js an Exectutive View
Node.js an Exectutive View
Manuel Eusebio de Paz Carmona
 
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
Olivier Bourgeois
 
Couch Db
Couch DbCouch Db
Couch Db
Ross Lawley
 
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
Valeriy Kravchuk
 
rubyonrails
rubyonrailsrubyonrails
rubyonrails
tutorialsruby
 
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginxLSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
Marian Marinov
 
drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010
Florian 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 surface
Florian Latzel
 
CouchDB in The Room
CouchDB in The RoomCouchDB in The Room
CouchDB in The Room
Makoto Ohnami
 
Drush und Multisite: drush_multi
Drush und Multisite: drush_multiDrush und Multisite: drush_multi
Drush und Multisite: drush_multi
Florian Latzel
 
Apache Dispatch
Apache DispatchApache Dispatch
Apache Dispatch
Fred 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 Java
PawanMM
 
sysprog4
sysprog4sysprog4
sysprog4
Ahmed Mekkawy
 
PERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schemaPERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schema
FromDual GmbH
 
Java 2
Java 2Java 2
Active Data Stores at 30,000ft
Active Data Stores at 30,000ftActive Data Stores at 30,000ft
Active Data Stores at 30,000ft
Jeffrey 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
 
netbeans
netbeansnetbeans
netbeans
tutorialsruby
 

What's hot (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
 

Similar to Doctrine Project

Zend Framework MVC driven ExtJS
Zend Framework MVC driven ExtJSZend Framework MVC driven ExtJS
Zend Framework MVC driven ExtJS
Thorsten Suckow-Homberg
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
Matteo Moretti
 
Scaling symfony apps
Scaling symfony appsScaling symfony apps
Scaling symfony apps
Matteo 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.pdf
ssuser705051
 
Terraform-2.pdf
Terraform-2.pdfTerraform-2.pdf
Terraform-2.pdf
rutiksankapal21
 
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 NoSQL
OSInet
 
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
scorlosquet
 
Drupal 7 and RDF
Drupal 7 and RDFDrupal 7 and RDF
Drupal 7 and RDF
scorlosquet
 
[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 Database
FITC
 
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
Angela 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 2012
scorlosquet
 
New paradigms
New paradigmsNew paradigms
Drupal training-1-in-mumbai
Drupal training-1-in-mumbaiDrupal training-1-in-mumbai
Drupal training-1-in-mumbai
vibrantuser
 
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
Acquia
 
Ubuntu scope development
Ubuntu scope developmentUbuntu scope development
Ubuntu scope development
Xiaoguo Liu
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
Marcelo 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
 
Goodpractice
GoodpracticeGoodpractice
Goodpractice
Lorna Mitchell
 

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

Recently uploaded

Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 

Recently uploaded (20)

Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 

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á =)