Upload
jonathan-wage
View
2.191
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Presentation on the Doctrine ORM from phpDay 2009 in Verona, Italy
Citation preview
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
What’s newin Doctrine
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Doctrine Book
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
First official publishedDoctrine documentation
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Doctrine 1.1
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Doctrine 2.0
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Doctrine 1.1
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
1.x Evolution
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Stability, bugs, features
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Zero failing test cases
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Dozens of new test cases adding more
code coverage
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Fine tuned API
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Improved HydrationPerformance
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Hydrate largerresult sets in less time
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Re-written documentation
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Misc. Features
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
New configuration options
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Better custommutator and accessor
support
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Enhanced fromArray()and
synchronizeWithArray()
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
HandlesRelationships
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
$userData = array( 'username' => 'jwage', 'password' => 'changeme', 'Groups' => array( array( '_identifier' => 1, ), array( '_identifier' => 2 ), array( 'name' => 'New Group' ) ));
$user = new User();$user->fromArray($userData);
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Generate phpDocproperty tags
/** * BaseUser * * This class has been auto-generated by the Doctrine ORM Framework * * @property string $username * @property string $password * * @package ##PACKAGE## * @subpackage ##SUBPACKAGE## * @author ##NAME## <##EMAIL##> * @version SVN: $Id: Builder.php 5441 2009-01-30 22:58:43Z jwage $ */abstract class BaseUser extends Doctrine_Record{ public function setTableDefinition() { $this->setTableName('user'); $this->hasColumn('username', 'string', 255, array('type' => 'string', 'length' => '255')); $this->hasColumn('password', 'string', 255, array('type' => 'string', 'length' => '255')); }}
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Used for IDEautocomplete, etc.
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Migrations
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
General improvementsall around to make
things more intuitive
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Brand New Diff tool
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Generate migration classes
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
By comparing twoDoctrine schemas
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Automate deploymentof database changes
User: columns: username: string(255) password: string(255)
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
From Schema
User: columns: username: string(255) password: string(255) email_address: string(255)
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
To Schema
$from = 'schema/from.yml';$to = 'schema/to.yml';$migrationsDir = 'migrations';$diff = new Doctrine_Migration_Diff($from, $to, $migrationsDir);$changes = $diff->generateChanges();
print_r($changes);
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Generating Changes
Array( [created_columns] => Array ( [user] => Array ( [email_address] => Array ( [type] => string [length] => 255 )
)
))
$from = 'schema/from.yml';$to = 'schema/to.yml';$migrationsDir = 'migrations';$diff = new Doctrine_Migration_Diff($from, $to, $migrationsDir);$diff->generateMigrationClasses();
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Generating Classes
// migrations/1239913213_version1.php
class Version1 extends Doctrine_Migration_Base{ public function up() { $this->addColumn('user', 'email_address', 'string', '255', array('email' => '1')); }
public function down() { $this->removeColumn('user', 'email_address'); }}
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Generating Classes
$migration = new Doctrine_Migration('migrations');$migration->migrate();
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Migrating ChangesMigrate from version 0 to version 1
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Migrating up executes up() methods
Migrating down executes down() methods
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
$migration = new Doctrine_Migration('migrations');$migration->migrate(0);
Reversing ChangesMigrate from version 1 to version 0
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
New DataHydration
Types
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Scalar
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Flat, rectangularresult set
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Faster to execute
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Harder to work with
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Can contain duplicate data
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Like normal SQLresult set
$q = Doctrine::getTable('User') ->createQuery('u') ->leftJoin('u.Phonenumbers p');
$results = $q->execute(array(), Doctrine::HYDRATE_SCALAR);
print_r($results);
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Scalar Example
Array( [0] => Array ( [u_id] => 1 [u_username] => jwage [u_password] => changeme [u_email_address] => [email protected] [p_id] => 1 [p_user_id] => 1 [p_phonenumber] => 16155139185 )
[1] => Array ( [u_id] => 1 [u_username] => jwage [u_password] => changeme [u_email_address] => [email protected] [p_id] => 2 [p_user_id] => 1 [p_phonenumber] => 14159925468 )
) What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Scalar Example
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Single Scalar
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Sub-type of Scalar
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Returns singlescalar value
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Useful for retrievingsingle value for
aggregate/calculated results
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Very fastNo need to hydrate
objects
$q = Doctrine::getTable('User') ->createQuery('u') ->select('COUNT(p.id) as num_phonenumbers') ->leftJoin('u.Phonenumbers p');
$results = $q->execute(array(), Doctrine::HYDRATE_SINGLE_SCALAR);
echo $results; // 2
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Single Scalar Example
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Doctrine 2.0
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
PHP 5.3
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Performance increases from 5.3
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Test suite runs20% faster
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
And uses 30%less memory
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Re-Design
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Simplified thepublic API
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Heavily influencedby JPA, Java Hibernate
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Smaller footprint
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Un-necessaryclutter removed
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
RemovedLimitations
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
class User extends Doctrine_Record{ public function setTableDefinition() { $this->hasColumn('id', 'integer', null, array( 'primary' => true, 'auto_increment' => true ));
$this->hasColumn('username', 'string', 255); }}
No need to extendDoctrine 1
/** * @DoctrineEntity * @DoctrineTable(name="user") */class User{ /** * @DoctrineId * @DoctrineColumn(type="integer") * @DoctrineGeneratedValue(strategy="auto") */ public $id;
/** * @DoctrineColumn(type="varchar", length=255) */ public $username;}
Doctrine 2
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
No more crazy cyclic references
User Object( [id] => [username] => jwage)
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
print_r() your objects
$user = new User();$user->username = 'jwage';print_r($user);
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Positive effects of removing the base
class all around
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
No more shared identitymap across connections
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
GeneralImprovements
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Code de-coupled
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
3 Main Packages
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Common
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
DBAL
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
ORM
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Use Doctrine DBALseparate from the ORM
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Easier to extend and override things
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Better support formultiple databases
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Sequences, schemasand catalogs
$config = new \Doctrine\ORM\Configuration();$eventManager = new \Doctrine\Common\EventManager();$connectionOptions = array( 'driver' => 'pdo_sqlite', 'path' => 'database.sqlite');$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config, $eventManager);
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Simplified connectioninformation
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
No more DSN nightmares
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Connection informationspecified as arrays
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Removed oldattribute system
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Replaced with simplerstring based system
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Real Native SQL support
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Driver BasedMeta Data
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
/** * @DoctrineEntity * @DoctrineTable(name="user") */class User{ /** * @DoctrineId * @DoctrineColumn(type="integer") * @DoctrineGeneratedValue(strategy="auto") */ public $id;
/** * @DoctrineColumn(type="varchar", length=255) */ public $username;}
PHP Annotations
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
PHP Codeclass User{ public $id, $username;}
$metadata = new ClassMetadata('User');
$metadata->mapField(array( 'fieldName' => 'id', 'type' => 'integer', 'id' => true));
$metadata->setIdGeneratorType('auto');
$metadata->mapField(array( 'fieldName' => 'username', 'type' => 'varchar', 'length' => 255));
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
YAML
User: properties: id: id: true type: integer idGenerator: auto username: type: varchar length: 255
class User{ public $id, $username;}
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Write your own driver
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Cache
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Query CacheCache final SQL that is parsed from DQL
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Metadata CacheCache the parsing of meta data
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Result CacheCache the results of your queries
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
InheritanceMapping
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Single TableOne table per hierarchy
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Class TableOne table per class
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Concrete TableOne table per concrete class
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Testing
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Switched to phpUnit
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Better mock testing
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Easy to run tests against multiple DBMS
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Code de-coupled soit is easier to test
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
New Features
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
New DQL Parser
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Hand written
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Recursive-descentparser
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Constructs AST
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
PHP Class namesdirectly represent
DQL language
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Every DQL featurehas a class to handle
parsing
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Easy to maintainEasy to add new features
Easy to use
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Performance?
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Final SQL can beeasily and effectively
cached
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Not practical to parseevery time
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
CustomColumn Types
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Add your own data types
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Types are OOP classes
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Easy to extendor add new types
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Extend DQL
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
DQL parser canbe extended
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Add your ownDQL functions
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
When?
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
First releasein September
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
ALPHA
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
BETA
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
RC
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Stable - 2010’ ?
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
What is next?
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Publishing of firstDoctrine book
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Write more documentation
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Publish more books
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Doctrine communityextension repository
Symfony has Plugins
and
Doctrine has Extensions
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Default DBALand ORM in PEAR2?
De-facto standard?
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
It is up to you! :)
You can contact Jonathan about Doctrine and Open-Source or for training, consulting, application development, or business related
questions at [email protected]
What’s new in Doctrine www.doctrine-project.org www.sensiolabs.com
#phpday
Jonathan H. [email protected]+1 415 992 5468
sensiolabs.com | doctrine-project.org | sympalphp.org | jwage.com
Questions?