Doctrine is a PHP library that provides persistence services and related functionality. It includes an object relational mapper (ORM) for mapping database records to PHP objects, and a database abstraction layer (DBAL). Other libraries include an object document mapper (ODM) for NoSQL databases, common annotations, caching, data fixtures, and migrations. The presentation provides an overview of each library and how to use Doctrine for common tasks like mapping classes, saving and retrieving objects, and schema migrations. Help and contribution opportunities are available on Google Groups, IRC channels, and the project's GitHub page.
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
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
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
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!
38. DBALMigrations
â $ doctrine-migrations:generate
Generated new migration class to
"/path/to/migrations/classes/DoctrineMigrations/Ve
rsion20100416130422.php"
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