SlideShare a Scribd company logo
1 of 24
Download to read offline
Integrating Doctrine
with Laravel
Mark Garratt - London Laravel Meetup - October 2015
Introduction
PHP Developer
DDD Student
Architecture Enthusiast
Metalhead
Archer
This Talk
What is Doctrine?
Installing Doctrine in Laravel
Replacing Eloquent
Using Doctrine
https://github.com/mgarratt/
laravel-doctrine-example
What is Doctrine?
• Doctrine is an ORM based on the Data Mapper Pattern
• Has it’s own underlying DBAL supporting MySQL,
PostgreSQL and MSSQL
• Uses a proprietary object oriented SQL dialect called
Doctrine Query Language (DQL)
• Store metadata as Annotations, XML, YAML or custom
implementations
• Uses Unit of Work Pattern to reduce database queries
How does it work?
• Models are Plain Old PHP Objects called Entities
• Entities are persisted through an EntityManager
• Entities are retrieved through a Repository
• Schema defined using Entity Metadata
LaravelDoctrine.org
• Preconfigured metadata,
connections and caching
• Annotations, yaml, xml, config
and static php meta data
mappings
• Pagination
• Extendable: extend or add your
own drivers for metadata,
connections or cache
• Change metadata, connection
or cache settings easy with a
resolved hook
LaravelDoctrine.org
• Multiple entity managers and
connections
• Simple authentication
implementation
• Password reminders
implementation
• Doctrine console commands
• DoctrineExtensions supported
• Timestamps, Softdeletes and
TablePrefix listeners
Replacing Eloquent with
Doctrine
• Remove extends model
• Replace Authenticatable
Trait and Contract
• Include ORM Mapping and
Timestamps
• Add fields, getters, setters
• Annotate everything
Replacing Eloquent with
Doctrine
• Update AuthController
validation to use Doctrine
unique syntax
• Replace AuthController
create with a version that uses
EntityManager
• Replace
PasswordController
resetPassword with a version
that uses EntityManager
Where are we now?
• Doctrine in use instead of Eloquent
• Separated persistence from entities
• Standard Authentication and Password Reset working
• Replaced save calls with global EntityManager
• Lost ability to query and save from entities
• Entities must be persisted and flushed to get an ID
• Also missing: Migrations & Seeds
Remove EntityManager Alias
• Begin using the Repository
Pattern
• EntityManger injected to
Repository
• Repository deals with storing
and retrieving entities only
Built in EntityRepository
• Repositories extend
EntityRepository
• Constructed with
EntityManager and
ClassMetaData
• Provides find() findAll()
findBy() and generic
matching() methods
FlushEntityManager
Middleware
• Calling persist on
EntityManager adds those
changes to the Unit of Work
• flush() must be called to
actually persist to the DB
• Add a Middleware to do this at
the end of every request
Application Generated IDs
• Use ramsey/uuid library -
RFC 4122 version 1, 3, 4, and
5 compliant
• Create global uuid() function
to return a UUID V4
• Use named constructors
• Update metadata so ID is a
string and Generator Strategy
is NONE
Migrations
• Provided by laravel-­‐doctrine/migrations
• No need to write yourself

php	
  artisan	
  doctrine:migrations:diff	
  
• Update your Entities then re-run diff to create a
new migration
• Run migrations using

php	
  artisan	
  doctrine:migrations:migrate
Seeds
• Work exactly the same
• Work directly with DBAL
• Create Entities and persist
• Model Factories do not work
(they’re part of Eloquent)
Switch to YAML Mapping
• Config doctrine.managers.default.path defines
where YAML files are stored
• Files named as fully qualified name with slashes
replaced by dots: App.User.dcm.yml

(dcm = Doctrine Mapping File)
• Also need a mapping for LaravelDoctrineORM
AuthPasswordsPasswordReminder
What has this achieved?
Gone from an application that depends on a SQL database to an
application that happens to be persisted on an SQL database
• Doctrine replaced with Eloquent
• Strong separation of concerns - Repositories deal with
persistence, Entities deal with business logic
• ID creation responsibility of the application
• Huge amount of Laravel functionality preserved
• Good foundation for DDD-style application
Moving Forward
• Build up methods in repository
• Take advantage of Laravel
Doctrine pagination
• Learn about Query Builder
and DQL
Obligatory Questions /
Contact Slide
Any Questions?
Mark Garratt

Twitter: @MGarratt88

GitHub: mgarratt
https://joind.in/15859

More Related Content

What's hot

Nutritional Assessment by Dr. Vinod G. Nikam
Nutritional Assessment by Dr. Vinod G. Nikam Nutritional Assessment by Dr. Vinod G. Nikam
Nutritional Assessment by Dr. Vinod G. Nikam Vinod Nikam
 
quality control in clinical laboratory
quality control in clinical laboratory quality control in clinical laboratory
quality control in clinical laboratory DrmanarEmam
 
Bacterial count, method to count bacteria
Bacterial count, method to count bacteriaBacterial count, method to count bacteria
Bacterial count, method to count bacteriaDrSampuranSuahg
 
WESTGARD RULES 2.pptx
WESTGARD RULES 2.pptxWESTGARD RULES 2.pptx
WESTGARD RULES 2.pptxVRAGHAVI
 
clinical chemistry investigation for primary health care
 clinical chemistry investigation for primary health care  clinical chemistry investigation for primary health care
clinical chemistry investigation for primary health care Yakubu Sunday Bot
 
Factors causing spoilage
Factors causing spoilageFactors causing spoilage
Factors causing spoilageJasmineJuliet
 
Microtome Procedure
Microtome ProcedureMicrotome Procedure
Microtome ProcedureMicrotomy
 
Nutritional requirements
Nutritional requirementsNutritional requirements
Nutritional requirementskomalojha
 

What's hot (9)

Nutritional Assessment by Dr. Vinod G. Nikam
Nutritional Assessment by Dr. Vinod G. Nikam Nutritional Assessment by Dr. Vinod G. Nikam
Nutritional Assessment by Dr. Vinod G. Nikam
 
quality control in clinical laboratory
quality control in clinical laboratory quality control in clinical laboratory
quality control in clinical laboratory
 
Bacterial count, method to count bacteria
Bacterial count, method to count bacteriaBacterial count, method to count bacteria
Bacterial count, method to count bacteria
 
WESTGARD RULES 2.pptx
WESTGARD RULES 2.pptxWESTGARD RULES 2.pptx
WESTGARD RULES 2.pptx
 
clinical chemistry investigation for primary health care
 clinical chemistry investigation for primary health care  clinical chemistry investigation for primary health care
clinical chemistry investigation for primary health care
 
Factors causing spoilage
Factors causing spoilageFactors causing spoilage
Factors causing spoilage
 
Microtome Procedure
Microtome ProcedureMicrotome Procedure
Microtome Procedure
 
Nutritional requirements
Nutritional requirementsNutritional requirements
Nutritional requirements
 
Identification of bacteria
Identification of bacteriaIdentification of bacteria
Identification of bacteria
 

Similar to Integrating Doctrine ORM with Laravel Framework

Hibernate in XPages
Hibernate in XPagesHibernate in XPages
Hibernate in XPagesToby Samples
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworksKirk Madera
 
New Persistence Features in Spring Roo 1.1
New Persistence Features in Spring Roo 1.1New Persistence Features in Spring Roo 1.1
New Persistence Features in Spring Roo 1.1Stefan Schmidt
 
6 Months PHP internship in Noida
6 Months PHP internship in Noida6 Months PHP internship in Noida
6 Months PHP internship in NoidaTech Mentro
 
Iterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternIterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternNitin Bhide
 
LDP4j: A framework for the development of interoperable read-write Linked Da...
LDP4j: A framework for the development of interoperable read-write Linked Da...LDP4j: A framework for the development of interoperable read-write Linked Da...
LDP4j: A framework for the development of interoperable read-write Linked Da...Nandana Mihindukulasooriya
 
Solr Recipes Workshop
Solr Recipes WorkshopSolr Recipes Workshop
Solr Recipes WorkshopErik Hatcher
 
Drupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDrupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDavid Lanier
 
Integrating the Solr search engine
Integrating the Solr search engineIntegrating the Solr search engine
Integrating the Solr search engineth0masr
 
9780538745840 ppt ch10
9780538745840 ppt ch109780538745840 ppt ch10
9780538745840 ppt ch10Terry Yoast
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentationManav Prasad
 
Modules Building Presentation
Modules Building PresentationModules Building Presentation
Modules Building Presentationhtyson
 

Similar to Integrating Doctrine ORM with Laravel Framework (20)

Hibernate in XPages
Hibernate in XPagesHibernate in XPages
Hibernate in XPages
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworks
 
New Persistence Features in Spring Roo 1.1
New Persistence Features in Spring Roo 1.1New Persistence Features in Spring Roo 1.1
New Persistence Features in Spring Roo 1.1
 
6 Months PHP internship in Noida
6 Months PHP internship in Noida6 Months PHP internship in Noida
6 Months PHP internship in Noida
 
Laravel ppt
Laravel pptLaravel ppt
Laravel ppt
 
Talend big data online training
Talend big data online trainingTalend big data online training
Talend big data online training
 
Iterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternIterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design pattern
 
LDP4j: A framework for the development of interoperable read-write Linked Da...
LDP4j: A framework for the development of interoperable read-write Linked Da...LDP4j: A framework for the development of interoperable read-write Linked Da...
LDP4j: A framework for the development of interoperable read-write Linked Da...
 
Solr Recipes Workshop
Solr Recipes WorkshopSolr Recipes Workshop
Solr Recipes Workshop
 
Require.JS
Require.JSRequire.JS
Require.JS
 
Hibernate
HibernateHibernate
Hibernate
 
Drupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDrupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 version
 
Integrating the Solr search engine
Integrating the Solr search engineIntegrating the Solr search engine
Integrating the Solr search engine
 
70487.pdf
70487.pdf70487.pdf
70487.pdf
 
9780538745840 ppt ch10
9780538745840 ppt ch109780538745840 ppt ch10
9780538745840 ppt ch10
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
 
Modules Building Presentation
Modules Building PresentationModules Building Presentation
Modules Building Presentation
 
Doctrine2
Doctrine2Doctrine2
Doctrine2
 
Doctrine2 enterpice
Doctrine2 enterpiceDoctrine2 enterpice
Doctrine2 enterpice
 

Recently uploaded

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 

Integrating Doctrine ORM with Laravel Framework

  • 1. Integrating Doctrine with Laravel Mark Garratt - London Laravel Meetup - October 2015
  • 3. This Talk What is Doctrine? Installing Doctrine in Laravel Replacing Eloquent Using Doctrine https://github.com/mgarratt/ laravel-doctrine-example
  • 4. What is Doctrine? • Doctrine is an ORM based on the Data Mapper Pattern • Has it’s own underlying DBAL supporting MySQL, PostgreSQL and MSSQL • Uses a proprietary object oriented SQL dialect called Doctrine Query Language (DQL) • Store metadata as Annotations, XML, YAML or custom implementations • Uses Unit of Work Pattern to reduce database queries
  • 5. How does it work? • Models are Plain Old PHP Objects called Entities • Entities are persisted through an EntityManager • Entities are retrieved through a Repository • Schema defined using Entity Metadata
  • 6. LaravelDoctrine.org • Preconfigured metadata, connections and caching • Annotations, yaml, xml, config and static php meta data mappings • Pagination • Extendable: extend or add your own drivers for metadata, connections or cache • Change metadata, connection or cache settings easy with a resolved hook
  • 7. LaravelDoctrine.org • Multiple entity managers and connections • Simple authentication implementation • Password reminders implementation • Doctrine console commands • DoctrineExtensions supported • Timestamps, Softdeletes and TablePrefix listeners
  • 8.
  • 9.
  • 10.
  • 11. Replacing Eloquent with Doctrine • Remove extends model • Replace Authenticatable Trait and Contract • Include ORM Mapping and Timestamps • Add fields, getters, setters • Annotate everything
  • 12. Replacing Eloquent with Doctrine • Update AuthController validation to use Doctrine unique syntax • Replace AuthController create with a version that uses EntityManager • Replace PasswordController resetPassword with a version that uses EntityManager
  • 13. Where are we now? • Doctrine in use instead of Eloquent • Separated persistence from entities • Standard Authentication and Password Reset working • Replaced save calls with global EntityManager • Lost ability to query and save from entities • Entities must be persisted and flushed to get an ID • Also missing: Migrations & Seeds
  • 14. Remove EntityManager Alias • Begin using the Repository Pattern • EntityManger injected to Repository • Repository deals with storing and retrieving entities only
  • 15. Built in EntityRepository • Repositories extend EntityRepository • Constructed with EntityManager and ClassMetaData • Provides find() findAll() findBy() and generic matching() methods
  • 16. FlushEntityManager Middleware • Calling persist on EntityManager adds those changes to the Unit of Work • flush() must be called to actually persist to the DB • Add a Middleware to do this at the end of every request
  • 17. Application Generated IDs • Use ramsey/uuid library - RFC 4122 version 1, 3, 4, and 5 compliant • Create global uuid() function to return a UUID V4 • Use named constructors • Update metadata so ID is a string and Generator Strategy is NONE
  • 18. Migrations • Provided by laravel-­‐doctrine/migrations • No need to write yourself
 php  artisan  doctrine:migrations:diff   • Update your Entities then re-run diff to create a new migration • Run migrations using
 php  artisan  doctrine:migrations:migrate
  • 19. Seeds • Work exactly the same • Work directly with DBAL • Create Entities and persist • Model Factories do not work (they’re part of Eloquent)
  • 20. Switch to YAML Mapping • Config doctrine.managers.default.path defines where YAML files are stored • Files named as fully qualified name with slashes replaced by dots: App.User.dcm.yml
 (dcm = Doctrine Mapping File) • Also need a mapping for LaravelDoctrineORM AuthPasswordsPasswordReminder
  • 21.
  • 22. What has this achieved? Gone from an application that depends on a SQL database to an application that happens to be persisted on an SQL database • Doctrine replaced with Eloquent • Strong separation of concerns - Repositories deal with persistence, Entities deal with business logic • ID creation responsibility of the application • Huge amount of Laravel functionality preserved • Good foundation for DDD-style application
  • 23. Moving Forward • Build up methods in repository • Take advantage of Laravel Doctrine pagination • Learn about Query Builder and DQL
  • 24. Obligatory Questions / Contact Slide Any Questions? Mark Garratt
 Twitter: @MGarratt88
 GitHub: mgarratt https://joind.in/15859