The document provides an overview of Doctrine 2, an object-relational mapper (ORM) for PHP. Some key points:
- Doctrine 2 has been completely rewritten from Doctrine 1 and requires PHP 5.3. It uses namespaces, has a new architecture and workflow.
- It provides a database abstraction layer (DBAL), object relational mapper (ORM), and common utilities. The DBAL can be used independently of the ORM.
- Entities do not need to extend a base class. Metadata is provided via annotations, YAML or XML.
- Performance is improved over Doctrine 1 through optimizations like a faster hydration algorithm.
- The architecture separates
This document provides an introduction and overview of Doctrine 2. Some key points:
- Doctrine 2 has been completely rewritten for PHP 5.3, with a new codebase and architecture.
- It has separate packages for the Common code, Database Abstraction Layer (DBAL), and Object-Relational Mapper (ORM).
- Entities no longer need to extend a base class and the domain model is defined purely with PHP objects.
- Initial performance tests show Doctrine 2 is significantly faster than Doctrine 1 at common tasks like hydrating thousands of records.
- The goal was to remove "magic" from Doctrine 1 to make it more explicit and
Up and running with doctrine 2 and zend framework 1Nurul Ferdous
This document discusses using Doctrine 2 as an ORM with Zend Framework 1.10. It explains what Doctrine is, why it should be used, and how to set it up with Zend Framework. It provides examples of inserting records with Doctrine 2 versus raw PHP code, showing Doctrine 2 is faster due to transaction handling. It also demonstrates how to configure a blog module with Doctrine 2, define entities, generate the schema, and perform basic CRUD operations.
Doctrine 2: Enterprise Persistence Layer for PHPJonathan Wage
Doctrine 2 is an object relational mapper (ORM) for PHP 5.3+ that sits on top of a powerful database abstraction layer (DBAL). One of its key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL), inspired by Hibernates HQL. This provides developers with a powerful alternative to SQL that maintains flexibility without requiring unnecessary code duplication.
The document discusses some key differences and improvements in Doctrine 2 compared to Doctrine 1. It notes that Doctrine 2 has a completely rewritten codebase for PHP 5.3 that results in much better performance. It also removes magical aspects that could be difficult to debug. Overall, Doctrine 2 aims to be more explicit and less magical through an object-oriented design.
Feihong talks about PEP 3156 and basic usage of Tulip, the reference implementation.
Video: http://pyvideo.org/video/2194/asynchronous-io-in-python-3
Source code: https://github.com/feihong/tulip-talk/
Multithreading and concurrency in androidRakesh Jha
Here you will learn -
What is Multithreading
What is concurrency
Process Vs Thread
Improvements and issues with concurrency
Limits of concurrency gains
Concurrency issues
Threads pools with the Executor Framework
AsyncTask and the UI Thread
Code
Learn JAVA tutorial -This Java tutorial is specially prepared for the Beginners who wants to learn Java programming language from the basics. This tutorial is prepared by Easy Web Solutions by PSK Technologies located in Nagpur that provides best training in Java,PHP,Web Development Hardware and Networking and also provide Internship on all mentioned courses
This document provides an introduction and overview of Doctrine 2. Some key points:
- Doctrine 2 has been completely rewritten for PHP 5.3, with a new codebase and architecture.
- It has separate packages for the Common code, Database Abstraction Layer (DBAL), and Object-Relational Mapper (ORM).
- Entities no longer need to extend a base class and the domain model is defined purely with PHP objects.
- Initial performance tests show Doctrine 2 is significantly faster than Doctrine 1 at common tasks like hydrating thousands of records.
- The goal was to remove "magic" from Doctrine 1 to make it more explicit and
Up and running with doctrine 2 and zend framework 1Nurul Ferdous
This document discusses using Doctrine 2 as an ORM with Zend Framework 1.10. It explains what Doctrine is, why it should be used, and how to set it up with Zend Framework. It provides examples of inserting records with Doctrine 2 versus raw PHP code, showing Doctrine 2 is faster due to transaction handling. It also demonstrates how to configure a blog module with Doctrine 2, define entities, generate the schema, and perform basic CRUD operations.
Doctrine 2: Enterprise Persistence Layer for PHPJonathan Wage
Doctrine 2 is an object relational mapper (ORM) for PHP 5.3+ that sits on top of a powerful database abstraction layer (DBAL). One of its key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL), inspired by Hibernates HQL. This provides developers with a powerful alternative to SQL that maintains flexibility without requiring unnecessary code duplication.
The document discusses some key differences and improvements in Doctrine 2 compared to Doctrine 1. It notes that Doctrine 2 has a completely rewritten codebase for PHP 5.3 that results in much better performance. It also removes magical aspects that could be difficult to debug. Overall, Doctrine 2 aims to be more explicit and less magical through an object-oriented design.
Feihong talks about PEP 3156 and basic usage of Tulip, the reference implementation.
Video: http://pyvideo.org/video/2194/asynchronous-io-in-python-3
Source code: https://github.com/feihong/tulip-talk/
Multithreading and concurrency in androidRakesh Jha
Here you will learn -
What is Multithreading
What is concurrency
Process Vs Thread
Improvements and issues with concurrency
Limits of concurrency gains
Concurrency issues
Threads pools with the Executor Framework
AsyncTask and the UI Thread
Code
Learn JAVA tutorial -This Java tutorial is specially prepared for the Beginners who wants to learn Java programming language from the basics. This tutorial is prepared by Easy Web Solutions by PSK Technologies located in Nagpur that provides best training in Java,PHP,Web Development Hardware and Networking and also provide Internship on all mentioned courses
Ruby 2.0 introduced several new features including keyword arguments, lazy enumerators, module#prepend, and default UTF-8 encoding. Keyword arguments allow defining method parameters with a new syntax for named arguments. Lazy enumerators let huge or infinite arrays be handled by controlling execution flow on the right side of enumerations. Module#prepend inserts a module in front of a class's ancestor chain, opposite of include. The default encoding was changed to UTF-8 to support all characters.
Our Essentials of Professional VLSI Digital Design Training helps you master VLSI technology concepts from basics to the advanced Verilog / System-Verilog Hardware
The document discusses FIX (Financial Information eXchange) protocol and challenges with working with its large specification. It proposes controlled code generation as a way to [1] generate parsers that translate FIX messages to records tailored for a specific use case, [2] handle the impedance mismatch between the full FIX specification and internal business logic, and [3] make the integration reusable for others. Key aspects include generating headers to define the required records and fields, parsers to handle syntax and semantics, and using a configuration file to determine which FIX messages and fields to support.
The document discusses concurrency and asynchronous techniques in Android. It explains that Android runs on multi-core devices so concurrency is important. It covers Java concurrency primitives like threads and executors. For Android, it recommends approaches like HandlerThread, AsyncTask, IntentService and Loader which are firmly based on the Java concurrency library. It cautions that AsyncTask behavior has changed and tasks may not run sequentially. It also provides examples of when different asynchronous techniques would be best used.
This document discusses the proxy pattern in PHP. It defines a proxy as an object whose interface sits between the client and a different object with the same interface. Proxies are commonly used for lazy loading, handling remote objects, implementing smart references, adding protection layers, and providing null object fallbacks. The document provides examples of implementing proxies for value holders, remote objects, smart references using weak references and registries, protection proxies, and null object fallback proxies. It also discusses how to implement the public API of a proxy class in PHP by extending the proxied class and rewriting its methods while handling public properties and serialization. Useful proxy libraries and code generation techniques are mentioned.
Martin Haagen presented on integrating Salesforce with external systems using web services. He discussed using web services for single sign-on and dynamic sharing to minimize data maintenance. Examples were shown of generating proxies from WSDLs to call .NET and PHP web services from Apex code using triggers or Visualforce. Hosting web services on the Force.com platform and security considerations like IP filtering were also covered. Demo code was provided on GitHub for outbound calls to .NET and PHP and tips discussed like avoiding callouts in loops and using mock classes for testing.
Hexagonal Architecture - PHP Barcelona Monthly Talk (DDD)Carlos Buenosvinos
This document discusses hexagonal architecture with PHP. It references a talk on domain-driven design from 2005. The main point is that hexagonal architecture allows an application to be driven equally by users, programs, tests or scripts, and to be developed and tested separately from runtime systems and databases. It provides demo code for a basic application demonstrating dependency inversion and another average application demonstrating using transactions and events.
What would your application look like if it was written by the people who write the testing frameworks? If unit tests make classes more modular, by forcing you to test it in isolation, then what is the effect of expanding this to a less granular level, the acceptance and functional test. The more modern application architecture evolves, the more we hear the very old patterns being rediscovered and re-adopted. 1979 Trygve's MVC is a classic example, so are the SOLID principles. In this talk we will look on how Symfony allows for a really decoupled, easy to test application, by following on the footsteps of Alistair Cockburn's hexagonal architecture.
The document discusses hexagonal architecture, also known as ports and adapters architecture. It is an alternative to traditional multi-layer architectures that aims to decouple the application core from external influences like databases, web frameworks, and other dependencies. The core domain logic is separated from external influences by defining application programming interfaces (APIs) called "ports" that external "adapters" implement. This allows the core to be developed and tested in isolation. The document provides an example implementation of a ticket management system using this architecture.
The document discusses hexagonal architecture and how it can be applied to PHP applications. It begins by defining software architecture and its importance. It then explains hexagonal architecture, which separates an application into distinct layers including domain, application, and infrastructure layers. The layers are decoupled via defined boundaries and interfaces. Commands are used to communicate between layers and are handled by command buses and handlers. Examples are given of implementing repositories, commands and handlers to follow this pattern in a PHP application.
A short introduction to the more advanced python and programming in general. Intended for users that has already learned the basic coding skills but want to have a rapid tour of more in-depth capacities offered by Python and some general programming background.
Execrices are available at: https://github.com/chiffa/Intermediate_Python_programming
This document provides an overview of Doctrine 2.0, an object-relational mapper (ORM) for PHP. It discusses the history and team behind Doctrine, differences between Doctrine 1 and 2, performance improvements in Doctrine 2, and use of PHP 5.3 features like namespaces. Key aspects covered include the EntityManager/transparent persistence, schema management through the DBAL, and support for relational and non-relational databases via the ORM and ODM.
The document provides an overview of topics that may be covered in DevOps and cloud engineering interviews. It includes questions on Linux, Kubernetes, Docker, shell scripting, the Amazon interview process, and networking. Sample questions are provided for each topic along with an example of Amazon's interview structure and common principles assessed. Key components, configurations, and commands are outlined for areas like containers, orchestration, configuration management, and continuous delivery.
Docker right now provides great value in the enterprise but the value proposition is more about developer productivity than scale-out.
Docker benefits include resource management, environment management, continuous delivery, developer and operations collaboration, and hybrid workloads.
Take care in its introduction. Consider Docker as just part of an overall toolkit and you don't need to go "full stack" to gain value.
This 2-day training course covers Behavior Driven Development (BDD) and automation testing using the Behat and Mink frameworks. Day 1 includes an overview of BDD, the Behat tool, and the Gherkin language. It demonstrates setting up a Behat project, writing feature files with scenarios, and implementing step definitions. Day 2 focuses on more advanced topics like the Mink library for web testing, configuration options, and best practices for BDD. Attendees will learn how to write automated tests for a website using Behat and execute them on the command line or within a browser. The course is suitable for testers and developers interested in BDD and gaining skills in PHP, Behat, and M
Browser Fuzzing with a Twist (and a Shake) -- ZeroNights 2015Jeremy Brown
The web client is critical software to secure from any perspective. No matter if you're an organization or a casual client, you're typically just as vulnerable as anyone else. OSes are often supplemented with hardening toolsets or built-in mitigations as an extra measure to avoid compromise, but as with all things, they aren't completely solid either. Thus the need for systems that break systems, some of which deploy fuzzing and almost all of them work to find implementation bugs. Browser fuzzing has been explored and improved in many different ways over the past several years. In this presentation, we'll be primarily talking about a mutation engine that provides a somewhat novel technique for finding bugs in a still-ripe attack surface: the browser's rendering engine. This technique has the flexibility to be applied even more broadly than browsers, for example, there's initial support for fuzzing PDF readers. We'll also be discussing the tooling and infrastructure areas of the process, detailing what's needed to build a system that will scale and enable your fuzzing strategies to be successful. Finally, we can conclude the talk with some incubation results and how you can start making use of these fuzzing techniques today to find the bugs you need to exploit browsers or identify and fix the code responsible for each vulnerability.
The code will print false, because paid = true assigns a local variable rather than setting the instance variable @paid. To fix it, use self.paid = true.
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
This document discusses the benefits of polyglot and poly-paradigm programming approaches for building more agile applications. It describes how using multiple languages and programming paradigms can optimize both performance and developer productivity. Specifically, it suggests that statically-typed compiled languages be used for core application components while dynamically-typed scripting languages connect and customize these components. This approach allows optimizing areas that require speed/efficiency separately from those requiring flexibility. The document also advocates aspects and functional programming to address cross-cutting concerns and concurrency challenges that arise in modern applications.
This document provides an overview and schedule for a Lucene Boot Camp training session. The training will cover topics like indexing, searching, performance tuning, and class projects. Participants will learn about indexing documents, querying with different query types, using filters and sorting, analyzing performance, and accessing term information. Hands-on exercises are included, as well as opportunities for participants to work on a class project to further apply and extend their Lucene knowledge. Resources and support are also mentioned for continuing to learn about Lucene after the training.
Ruby 2.0 introduced several new features including keyword arguments, lazy enumerators, module#prepend, and default UTF-8 encoding. Keyword arguments allow defining method parameters with a new syntax for named arguments. Lazy enumerators let huge or infinite arrays be handled by controlling execution flow on the right side of enumerations. Module#prepend inserts a module in front of a class's ancestor chain, opposite of include. The default encoding was changed to UTF-8 to support all characters.
Our Essentials of Professional VLSI Digital Design Training helps you master VLSI technology concepts from basics to the advanced Verilog / System-Verilog Hardware
The document discusses FIX (Financial Information eXchange) protocol and challenges with working with its large specification. It proposes controlled code generation as a way to [1] generate parsers that translate FIX messages to records tailored for a specific use case, [2] handle the impedance mismatch between the full FIX specification and internal business logic, and [3] make the integration reusable for others. Key aspects include generating headers to define the required records and fields, parsers to handle syntax and semantics, and using a configuration file to determine which FIX messages and fields to support.
The document discusses concurrency and asynchronous techniques in Android. It explains that Android runs on multi-core devices so concurrency is important. It covers Java concurrency primitives like threads and executors. For Android, it recommends approaches like HandlerThread, AsyncTask, IntentService and Loader which are firmly based on the Java concurrency library. It cautions that AsyncTask behavior has changed and tasks may not run sequentially. It also provides examples of when different asynchronous techniques would be best used.
This document discusses the proxy pattern in PHP. It defines a proxy as an object whose interface sits between the client and a different object with the same interface. Proxies are commonly used for lazy loading, handling remote objects, implementing smart references, adding protection layers, and providing null object fallbacks. The document provides examples of implementing proxies for value holders, remote objects, smart references using weak references and registries, protection proxies, and null object fallback proxies. It also discusses how to implement the public API of a proxy class in PHP by extending the proxied class and rewriting its methods while handling public properties and serialization. Useful proxy libraries and code generation techniques are mentioned.
Martin Haagen presented on integrating Salesforce with external systems using web services. He discussed using web services for single sign-on and dynamic sharing to minimize data maintenance. Examples were shown of generating proxies from WSDLs to call .NET and PHP web services from Apex code using triggers or Visualforce. Hosting web services on the Force.com platform and security considerations like IP filtering were also covered. Demo code was provided on GitHub for outbound calls to .NET and PHP and tips discussed like avoiding callouts in loops and using mock classes for testing.
Hexagonal Architecture - PHP Barcelona Monthly Talk (DDD)Carlos Buenosvinos
This document discusses hexagonal architecture with PHP. It references a talk on domain-driven design from 2005. The main point is that hexagonal architecture allows an application to be driven equally by users, programs, tests or scripts, and to be developed and tested separately from runtime systems and databases. It provides demo code for a basic application demonstrating dependency inversion and another average application demonstrating using transactions and events.
What would your application look like if it was written by the people who write the testing frameworks? If unit tests make classes more modular, by forcing you to test it in isolation, then what is the effect of expanding this to a less granular level, the acceptance and functional test. The more modern application architecture evolves, the more we hear the very old patterns being rediscovered and re-adopted. 1979 Trygve's MVC is a classic example, so are the SOLID principles. In this talk we will look on how Symfony allows for a really decoupled, easy to test application, by following on the footsteps of Alistair Cockburn's hexagonal architecture.
The document discusses hexagonal architecture, also known as ports and adapters architecture. It is an alternative to traditional multi-layer architectures that aims to decouple the application core from external influences like databases, web frameworks, and other dependencies. The core domain logic is separated from external influences by defining application programming interfaces (APIs) called "ports" that external "adapters" implement. This allows the core to be developed and tested in isolation. The document provides an example implementation of a ticket management system using this architecture.
The document discusses hexagonal architecture and how it can be applied to PHP applications. It begins by defining software architecture and its importance. It then explains hexagonal architecture, which separates an application into distinct layers including domain, application, and infrastructure layers. The layers are decoupled via defined boundaries and interfaces. Commands are used to communicate between layers and are handled by command buses and handlers. Examples are given of implementing repositories, commands and handlers to follow this pattern in a PHP application.
A short introduction to the more advanced python and programming in general. Intended for users that has already learned the basic coding skills but want to have a rapid tour of more in-depth capacities offered by Python and some general programming background.
Execrices are available at: https://github.com/chiffa/Intermediate_Python_programming
This document provides an overview of Doctrine 2.0, an object-relational mapper (ORM) for PHP. It discusses the history and team behind Doctrine, differences between Doctrine 1 and 2, performance improvements in Doctrine 2, and use of PHP 5.3 features like namespaces. Key aspects covered include the EntityManager/transparent persistence, schema management through the DBAL, and support for relational and non-relational databases via the ORM and ODM.
The document provides an overview of topics that may be covered in DevOps and cloud engineering interviews. It includes questions on Linux, Kubernetes, Docker, shell scripting, the Amazon interview process, and networking. Sample questions are provided for each topic along with an example of Amazon's interview structure and common principles assessed. Key components, configurations, and commands are outlined for areas like containers, orchestration, configuration management, and continuous delivery.
Docker right now provides great value in the enterprise but the value proposition is more about developer productivity than scale-out.
Docker benefits include resource management, environment management, continuous delivery, developer and operations collaboration, and hybrid workloads.
Take care in its introduction. Consider Docker as just part of an overall toolkit and you don't need to go "full stack" to gain value.
This 2-day training course covers Behavior Driven Development (BDD) and automation testing using the Behat and Mink frameworks. Day 1 includes an overview of BDD, the Behat tool, and the Gherkin language. It demonstrates setting up a Behat project, writing feature files with scenarios, and implementing step definitions. Day 2 focuses on more advanced topics like the Mink library for web testing, configuration options, and best practices for BDD. Attendees will learn how to write automated tests for a website using Behat and execute them on the command line or within a browser. The course is suitable for testers and developers interested in BDD and gaining skills in PHP, Behat, and M
Browser Fuzzing with a Twist (and a Shake) -- ZeroNights 2015Jeremy Brown
The web client is critical software to secure from any perspective. No matter if you're an organization or a casual client, you're typically just as vulnerable as anyone else. OSes are often supplemented with hardening toolsets or built-in mitigations as an extra measure to avoid compromise, but as with all things, they aren't completely solid either. Thus the need for systems that break systems, some of which deploy fuzzing and almost all of them work to find implementation bugs. Browser fuzzing has been explored and improved in many different ways over the past several years. In this presentation, we'll be primarily talking about a mutation engine that provides a somewhat novel technique for finding bugs in a still-ripe attack surface: the browser's rendering engine. This technique has the flexibility to be applied even more broadly than browsers, for example, there's initial support for fuzzing PDF readers. We'll also be discussing the tooling and infrastructure areas of the process, detailing what's needed to build a system that will scale and enable your fuzzing strategies to be successful. Finally, we can conclude the talk with some incubation results and how you can start making use of these fuzzing techniques today to find the bugs you need to exploit browsers or identify and fix the code responsible for each vulnerability.
The code will print false, because paid = true assigns a local variable rather than setting the instance variable @paid. To fix it, use self.paid = true.
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
This document discusses the benefits of polyglot and poly-paradigm programming approaches for building more agile applications. It describes how using multiple languages and programming paradigms can optimize both performance and developer productivity. Specifically, it suggests that statically-typed compiled languages be used for core application components while dynamically-typed scripting languages connect and customize these components. This approach allows optimizing areas that require speed/efficiency separately from those requiring flexibility. The document also advocates aspects and functional programming to address cross-cutting concerns and concurrency challenges that arise in modern applications.
This document provides an overview and schedule for a Lucene Boot Camp training session. The training will cover topics like indexing, searching, performance tuning, and class projects. Participants will learn about indexing documents, querying with different query types, using filters and sorting, analyzing performance, and accessing term information. Hands-on exercises are included, as well as opportunities for participants to work on a class project to further apply and extend their Lucene knowledge. Resources and support are also mentioned for continuing to learn about Lucene after the training.
Doctrine is an object relational mapper (ORM) built for PHP. It allows developers to work with PHP objects instead of directly with SQL. Some key features include the Doctrine Query Language (DQL) for writing object-oriented queries, support for relationships and associations between objects, and behaviors that add common functionality like timestamps and slugs. Doctrine aims to make working with databases and objects easier and more productive for PHP developers.
This presentation is a part of the MosesCore project that encourages the development and usage of open source machine translation tools, notably the Moses statistical MT toolkit. MosesCore is supported by the European Commission Grant Number 288487 under the 7th Framework Programme.
For the latest updates go to http://www.statmt.org/mosescore/
or follow us on Twitter - #MosesCore
This document summarizes a presentation about integrating the Doctrine ORM with Laravel. It discusses what Doctrine is, how to install and configure it with Laravel, replacing Eloquent with Doctrine, using repositories, migrations, seeds, and other features. The presentation shows how to transition an application from using Eloquent to Doctrine to achieve a stronger separation of concerns and set up a foundation for domain-driven design principles.
Solr 4.0 dramatically improves scalability, performance, and flexibility. An overhauled Lucene underneath sports near real-time (NRT) capabilities allowing indexed documents to be rapidly visible and searchable. Lucene’s improvements also include pluggable scoring, much faster fuzzy and wildcard querying, and vastly improved memory usage. These Lucene improvements automatically make Solr much better, and Solr magnifies these advances with “SolrCloud.” SolrCloud enables highly available and fault tolerant clusters for large scale distributed indexing and searching. There are many other changes that will be surveyed as well. This talk will cover these improvements in detail, comparing and contrasting to previous versions of Solr.
Stitch Fix aspires to help you find the style that you will love. Data, the backbone of the business, is used to help with styling recommendations, demand modeling, user acquisition, and merchandise planning and also to influence business decisions throughout the organization. These decisions are backed by algorithms and data collected and interpreted based on client preferences. Neelesh Srinivas Salian offers an overview of the compute infrastructure used by the data science team at Stitch Fix, covering the architecture, tools within the larger ecosystem, and the challenges that the team overcame along the way.
Apache Spark plays an important role in Stitch Fix’s data platform, and the company’s data scientists use Spark for their ETL and Presto for their ad hoc queries. The goal for the team running the compute infrastructure is to understand and make the data scientists’ lives easier, particularly in terms of usability of Spark, by building tools that expedite the process of getting started with Spark and transitioning from an ad hoc to a production workflow. The compute infrastructure is a part of the data platform that is responsible for all the needs of data scientists as Stitch Fix.
Neelesh shares Stitch Fix’s journey, exploring its ad hoc and production infrastructure and detailing its in-house tools and how they work in synergy with open source frameworks in a cloud environment. Neelesh also discusses the additional improvements to the infrastructure that help persist information for future use and optimization and explains how the implementation of Amazon’s EMR FS has helped make it easier to read from the S3 source.
Celery is an asynchronous task queue/job queue based on distributed message passing. It allows tasks to be executed concurrently on one or more worker servers to minimize request times and offload intensive processes. Some key benefits are improved user experience through faster responses, scalability by adding more workers as needed, and flexibility through many customization points. Celery uses message brokers like RabbitMQ to handle task routing and can integrate with databases, caching, and other services.
Agile Lab is an Italian company that specializes in leveraging innovative technologies like machine learning, big data, and artificial intelligence to satisfy customers' objectives. They have over 50 specialists with deep experience in production environments. The company believes in investing in its team through conferences, R&D projects, and welfare benefits. They also release open source frameworks on GitHub and share knowledge through meetups in Milan and Turin.
Similar to Doctrine 2 - Enterprise Persistence Layer For PHP (20)
Come to this talk prepared to learn about the Doctrine PHP open source project. The Doctrine project has been around for over a decade and has evolved from database abstraction software that dates back to the PEAR days. The packages provided by the Doctrine project have been downloaded almost 500 million times from packagist. In this talk we will take you through how to get started with Doctrine and how to take advantage of some of the more advanced features.
The document provides information about Jonathan Wage and the technology company OpenSky. It discusses OpenSky's business details like revenue, users, and curator partners. It also summarizes OpenSky's technology stack including programming languages, frameworks, databases, and messaging systems used to build their social e-commerce platform.
Doctrine In The Real World sflive2011 ParisJonathan Wage
The document discusses how the author's company OpenSky uses both the Doctrine ORM and ODM in their e-commerce application. Actions involving commerce like orders and transactions are stored in MySQL using the ORM, while other data like products, users, and suppliers are stored in MongoDB using the ODM. The author explains how they define entities and documents and blend the two systems by loading the MongoDB product document reference on the ORM order entity using a post-load lifecycle event listener.
This document provides an overview of key concepts for developing applications with Symfony2 including: setting up the framework, code flow, dependency injection, configuration, controllers, applications, Doctrine integration, caching, performance tips, asset management, testing, deployment, third party bundles, and resources for contributing to Symfony2. It discusses service definitions, controller choices, application choices, Doctrine examples, caching strategies, performance optimization techniques, testing approaches, deployment options, and how to work with third party bundles.
The document discusses how OpenSky, a commerce company, uses both Doctrine ORM and ODM to manage their data. It uses Doctrine ORM with MySQL to handle order and transaction data, while using Doctrine ODM with MongoDB to handle product and other non-financial data. It describes how OpenSky defines Product documents and Order entities, and how it loads the Product reference on an Order entity using a post-load lifecycle event listener.
Jonathan H. Wage is a PHP developer who works at OpenSky, an open source social commerce platform. He is also a contributor to the Doctrine project, which includes libraries for database abstraction, migrations, object-relational mapping (ORM), and object document mapping (ODM) for MongoDB and CouchDB. Doctrine started in 2006 and provides a way to work with database functionality in PHP objects instead of arrays. The Doctrine MongoDB ODM allows managing MongoDB data as PHP objects using a document manager to persist changes transparently through atomic operations.
Jonathan Wage is a PHP developer who has worked on the Doctrine project for over 10 years. He works at OpenSky, which uses PHP and several open source projects like Symfony and Doctrine. Doctrine is an open source ORM and database abstraction layer for PHP that was started in 2006 and includes libraries for object mapping, migrations, and working with MongoDB and CouchDB.
This document provides an overview of Doctrine MongoDB ODM (Object Document Mapper). It discusses what Doctrine is, what MongoDB is, basic MongoDB terminology, how to connect to and perform CRUD operations in MongoDB from PHP, and how Doctrine MongoDB ODM provides an abstraction layer and object mapping functionality for MongoDB documents.
Doctrine MongoDB ODM is an object document mapper for PHP that provides tools for managing object persistence with MongoDB. It allows developers to work with MongoDB documents as objects and provides a query API and change tracking functionality to make common operations like inserting, updating, and deleting documents straightforward. Doctrine abstracts away the low-level MongoDB driver to allow developers to work with documents and references between documents using familiar object-oriented patterns.
The document provides information about new features and integration of Symfony and Doctrine. It discusses updates to the DoctrineBundle and new bundles for MongoDB integration and database migrations. It also covers using the Doctrine database abstraction layer independently and the object relational mapper, including entity management, querying, and schema management.
Sympal is a content management system built on Symfony and Doctrine. It provides common CMS functionality through plugins while leveraging Symfony's flexibility. Key features include menus, breadcrumbs, content types, inline editing, and a plugin manager for installing additional functionality. Configuration is controlled through YAML files or a web interface.
The document discusses new features and changes in Symfony 1.3 and Doctrine 1.2. Propel is now deprecated as the default ORM, replaced by Doctrine. New features for Symfony include an installer option to execute scripts during project generation, and improved form handling using events. The form framework also supports selectively configuring fields rather than removing them. Testing was improved with new methods for asserting page content.
Sympal is an extension for the Symfony framework that adds content management capabilities. It includes core plugins for pages, menus, users and more. Additional plugins can be installed, such as for blogs or comments. Sympal aims to provide functionality similar to Drupal but using Symfony and with better code. It allows for custom content types and slots and includes features like inline editing and rich text.
The document describes Sympal, a flexible Symfony CMS. Sympal combines Drupal and Symfony to provide a powerful content management framework. It includes features like inline content editing, themes, custom content types, menu management, and security controls. Sympal aims to be flexible, extensible and configurable through plugins, events and configuration options at multiple levels. It can be installed via an interactive command line installer or in existing and new Symfony projects.
The document discusses what's new in various versions of the Doctrine ORM library. It highlights new features and improvements in Doctrine 1.1, documentation, testing, performance, migrations, hydration types, Doctrine 2.0 design, and general improvements. Key updates include re-written documentation, improved hydration performance, a new migrations system, scalar and single scalar hydration types for speed, and a simplified ORM design in Doctrine 2.0 without needing to extend a base class.
Unlocking Productivity: Leveraging the Potential of Copilot in Microsoft 365, a presentation by Christoforos Vlachos, Senior Solutions Manager – Modern Workplace, Uni Systems
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Best 20 SEO Techniques To Improve Website Visibility In SERPPixlogix Infotech
Boost your website's visibility with proven SEO techniques! Our latest blog dives into essential strategies to enhance your online presence, increase traffic, and rank higher on search engines. From keyword optimization to quality content creation, learn how to make your site stand out in the crowded digital landscape. Discover actionable tips and expert insights to elevate your SEO game.
Maruthi Prithivirajan, Head of ASEAN & IN Solution Architecture, Neo4j
Get an inside look at the latest Neo4j innovations that enable relationship-driven intelligence at scale. Learn more about the newest cloud integrations and product enhancements that make Neo4j an essential choice for developers building apps with interconnected data and generative AI.
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc
How does your privacy program stack up against your peers? What challenges are privacy teams tackling and prioritizing in 2024?
In the fifth annual Global Privacy Benchmarks Survey, we asked over 1,800 global privacy professionals and business executives to share their perspectives on the current state of privacy inside and outside of their organizations. This year’s report focused on emerging areas of importance for privacy and compliance professionals, including considerations and implications of Artificial Intelligence (AI) technologies, building brand trust, and different approaches for achieving higher privacy competence scores.
See how organizational priorities and strategic approaches to data security and privacy are evolving around the globe.
This webinar will review:
- The top 10 privacy insights from the fifth annual Global Privacy Benchmarks Survey
- The top challenges for privacy leaders, practitioners, and organizations in 2024
- Key themes to consider in developing and maintaining your privacy program
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
GraphRAG for Life Science to increase LLM accuracyTomaz Bratanic
GraphRAG for life science domain, where you retriever information from biomedical knowledge graphs using LLMs to increase the accuracy and performance of generated answers
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
7. Fully Namespaced
• Doctrine makes use of PHP 5.3 namespaces.
Currently we have the following
namespaces:
– DoctrineCommon
– DoctrineDBAL
– DoctrineORM
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
8. Common
• Standalone package containing all common
code shared between DBAL and ORM
– Cache drivers
– Annotations Parser
– Command Line Interface
– Class Loaders
– Lexer Parser
– ...and other various utilities
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
9. DBAL
• Database Abstraction Layer built on top of
PDO.
– Multiple DBMS supported
• MySQL
• Sqlite
• Pgsql
• etc.
– Database Introspection
– DDL Statment API
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
10. ORM
• Object Relational Mapper built on top of
Common and DBAL
– Inheritance
– Doctrine Query Language
– XML, YAML or Annotations Metadata
– Query Cache
– Result Cache
– ...much more
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
11. Complete separation of your
domain model and persistence
layer
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
12. We learned lots building Doctrine
1 and we used that to help us
build Doctrine 2
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
14. Performance of Doctrine 1
To hydrate 5000 records
in Doctrine 1 it takes
roughly 4.3 seconds.
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
15. Performance of Doctrine 2
Under Doctrine 2, hydrating
those same 5000 records only
takes 1.4 seconds.
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
16. Performance of Doctrine 2
...and with 10000 records it still
only takes about 3.5 seconds.
Twice the data and still faster
than Doctrine 1
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
17. Why is it faster?
• PHP 5.3 gives us a huge performance
improvement when using a heavily OO
framework like Doctrine
• Better optimized hydration algorithm
• Killed the magical aspect of Doctrine 1
• All around more explicit and less magical
code results in better and faster code.
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
18. Why kill the magic?
• Eliminate the WTF factor of Doctrine 1
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
19. The Doctrine 1 magical
features are both a
blessing and a curse
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
20. Blessing and a Curse
• Magic is great when it works
• The magic you love is also the cause of all
the pain you’ve felt with Doctrine 1
• When it doesn’t work it is hard to debug
• Edge cases are hard to fix
• Edge cases are hard to work around
• Edge cases, edge cases, edge cases
• Everything is okay until you try and go
outside the box the magic provides
• ...magic is slow
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
21. How will we replace the magic?
This new thing called OOP :)
• Object Composition
• Inheritance
• Aggregation
• Containment
• Encapsulation
• ...etc
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
22. Will Doctrine 2 have behaviors?
Yes and No
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
23. The No
• We won’t have any concept of “model
behaviors”
• Behaviors were a made up concept for
Doctrine 1 to work with its extremely
intrusive architecture.
• It tries to do things that PHP does not allow
and is the result of lots of problems in
Doctrine 1
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
24. The Yes
• Everything you can do in Doctrine 1 you can
do in Doctrine 2, just in a different way.
• “Behavior” like functionality will be bundled
as extensions for Doctrine 2 and will just
contain normal OO PHP code that wraps/
extends Doctrine code or is meant to be
wrapped or extended by your entities.
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
25. What did we use to build
Doctrine 2?
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
26. Doctrine 2 Tool Belt
• phpUnit 3.4.10 - Unit Testing
• Phing - Packaging and Distribution
• Symfony YAML Component
• Sismo - Continuous Integration
• Subversion - Source Control
• Jira - Issue Tracking and Management
• Trac - Subversion Timeline, Source Code
Browser, Changeset Viewer
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
27. Doctrine 2 Architecture
• Entities
• Lightweight persistent domain object
• Regular PHP class
• Does not extend any base Doctrine class
• Cannot be final or contain final methods
• Any two entities in a hierarchy of classes must not have a
mapped property with the same name
• Supports inheritance, polymorphic associations and
polymorphic queries.
• Both abstract and concrete classes can be entities
• Entities may extend non-entity classes as well as entity
classes, and non-entity classes may extend entity classes
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
28. Doctrine 2 Architecture
• Your entities in Doctrine 2 don’t require
that you extend a base class like in Doctrine
1! No more imposing on your domain
model!
namespace Entities;
class User
{
private $id;
private $name;
private $address;
}
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
29. Doctrine 2 Architecture
• The EntityManager
• Central access point to the ORM functionality provided by
Doctrine 2. API is used to manage the persistence of your
objects and to query for persistent objects.
• Employes transactional write behind strategy that delays the
execution of SQL statements in order to execute them in the
most efficient way
• Execute at end of transaction so that all write locks are quickly
releases
• Internally an EntityManager uses a UnitOfWork to keep track
of your objects
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
30. Unit Testing
• Tests are ran against multiple DBMS types.
This is something that was not possible
with the Doctrine 1 test suite.
• ...Sqlite
• ...MySQL
• ...Oracle
• ...PgSQL
• ...more to come
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
31. Unit Testing
• 859 Test Cases
• 2152 Assertions
• Tests run in a few seconds compared to
30-40 seconds for Doctrine 1
• Much more granular and explicit unit tests
• Easier to debug failed tests
• Continuously integrated by Sismo :)
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
32. Database Abstraction Layer
• Separate standalone package and
namespace (DoctrineDBAL).
• Can be used standalone.
• Much improved over Doctrine 1 in regards
to the API for database introspection and
schema management.
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
33. Database Abstraction Layer
• Hopefully Doctrine 2 DBAL can be the
defacto standard DBAL for PHP 5.3 in the
future like MDB and MDB2 were in PEAR
• Maybe we can make this happen for PEAR2?
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
34. DBAL Data API
• prepare($sql) - Prepare a given sql statement and return the DoctrineDBAL
DriverStatement instance.
• executeUpdate($sql, array $params) - Executes a prepared statement with the
given sql and parameters and returns the affected rows count.
• execute($sql, array $params) - Creates a prepared statement for the given sql and
passes the parameters to the execute method, then returning the statement.
• fetchAll($sql, array $params) - Execute the query and fetch all results into an array.
• fetchArray($sql, array $params) - Numeric index retrieval of first result row of the
given query.
• fetchBoth($sql, array $params) - Both numeric and assoc column name retrieval of
the first result row.
• fetchColumn($sql, array $params, $colnum) - Retrieve only the given column of
the first result row.
• fetchRow($sql, array $params) - Retrieve assoc row of the first result row.
• select($sql, $limit, $offset) - Modify the given query with a limit clause.
• delete($tableName, array $identifier) - Delete all rows of a table matching the
given identifier, where keys are column names.
• insert($tableName, array $data) - Insert a row into the given table name using the
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
36. DBAL Schema Representation
$platform = $em->getConnection()->getDatabasePlatform();
$schema = new DoctrineDBALSchemaSchema();
$myTable = $schema->createTable("my_table");
$myTable->addColumn("id", "integer", array("unsigned" => true));
$myTable->addColumn("username", "string", array("length" => 32));
$myTable->setPrimaryKey(array("id"));
// get queries to create this schema.
$queries = $schema->toSql($platform);
Array
(
[0] => CREATE TABLE my_table (id INTEGER NOT NULL, username VARCHAR(32) NOT NULL, PRIMARY KEY("id"))
)
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
37. DBAL Schema Representation
// ......
// get queries to safely delete this schema.
$dropSchema = $schema->toDropSql($platform);
Array
(
[0] => DROP TABLE my_table
)
Does the reverse of what toSql() does, dropping the created tables
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
38. Comparing Schemas
• Lets take our original my_table schema as
our “from schema”...
$fromSchema = new DoctrineDBALSchemaSchema();
$myTable = $fromSchema->createTable("my_table");
$myTable->addColumn("id", "integer", array("unsigned" => true));
$myTable->addColumn("username", "string", array("length" => 32));
$myTable->setPrimaryKey(array("id"));
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
39. Compare DBAL Schemas
• Then later you want to add a new column to
the schema and easily deploy the change.
• Lets add an email column to the table:
$toSchema = new DoctrineDBALSchemaSchema();
$myTable = $toSchema->createTable("my_table");
$myTable->addColumn("id", "integer", array("unsigned" => true));
$myTable->addColumn("username", "string", array("length" => 32));
$myTable->addColumn("email", "string", array("length" => 255));
$myTable->setPrimaryKey(array("id"));
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
40. Compare DBAL Schemas
• You can easily compare one schema to
another to deploy the changes!
$comparator = new DoctrineDBALSchemaComparator();
$schemaDiff = $comparator->compare($fromSchema, $toSchema);
// queries to get from one to another schema.
$queries = $schemaDiff->toSql($platform);
print_r($queries);
Array
(
[0] => ALTER TABLE my_table ADD email VARCHAR(255) NOT NULL
)
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
42. Things to Notice
• Entities no longer require you to extend a
base class
• Your domain model has absolutely no
magic
• Not imposed on by Doctrine and is defined
by raw PHP objects and normal OO
programming
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
50. Setup
• In production you would lazily load the
EntityManager
• Example: $em = function()
{
static $em;
if (!$em)
{
$em = EntityManager::create($connectionOptions, $config);
}
return $em;
}
• In the real world I wouldn’t recommend that
you use the above example
• Symfony DI would take care of this for us
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
51. use DoctrineCommonClassLoader,
DoctrineORMConfiguration,
DoctrineORMEntityManager,
DoctrineCommonCacheApcCache,
EntitiesUser,
EntitiesAddress;
require '/path/to/doctrine/lib/Doctrine/Common/ClassLoader.php';
$doctrineClassLoader = new ClassLoader('Doctrine', '/path/to/doctrine');
$doctrineClassLoader->register();
$entitiesClassLoader = new ClassLoader('Entities', '/path/to/entities');
$entitiesClassLoader->register();
$proxiesClassLoader = new ClassLoader('Proxies', '/path/to/proxies');
$proxiesClassLoader->register();
// Set up caches
$config = new Configuration;
$cache = new ApcCache;
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Proxy configuration
$config->setProxyDir('/path/to/proxies/Proxies');
$config->setProxyNamespace('Proxies');
// Database connection information
$connectionOptions = array(
'driver' => 'pdo_sqlite',
'path' => 'database.sqlite'
);
// Create EntityManager
$em = EntityManager::create($connectionOptions, $config);
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
52. Setup
• Now you can start using your models and
persisting entities
$user = new User;
$user->setName('Jonathan H. Wage');
$em->persist($user);
$em->flush();
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
53. Insert Performance
• Inserting 20 records with Doctrine
for ($i = 0; $i < 20; ++$i) {
$user = new User;
$user->name = 'Jonathan H. Wage';
$em->persist($user);
}
$s = microtime(true);
$em->flush();
$e = microtime(true);
echo $e - $s;
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
54. Insert Performance
• Compare it to some raw PHP code
$s = microtime(true);
for ($i = 0; $i < 20; ++$i) {
mysql_query("INSERT INTO users (name) VALUES ('Jonathan H. Wage')",
$link);
}
$e = microtime(true);
echo $e - $s;
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
55. Insert Performance
• The results might be surprising to you.
Which do you think is faster?
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
57. Insert Performance
• Doctrine 2 is faster than some raw PHP
code? What?!?!?! HUH?
• It does a lot less, provides no features, no
abstraction, etc.
• Why? The answer is transactions! Doctrine 2
manages our transactions for us and
efficiently executes all inserts in a single.
The raw PHP code executes 1 transaction
for each insert.
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
58. Insert Performance
• Doctrine 2 is not faster than some raw PHP
code
• The example demonstrates that simple
developer oversights and can cause
significant performance problems
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
59. Insert Performance
• Here is the same raw PHP code re-visited
with proper transaction usage.
$s = microtime(true);
mysql_query('START TRANSACTION', $link);
for ($i = 0; $i < 20; ++$i) {
mysql_query("INSERT INTO users (name) VALUES ('Jonathan H. Wage')",
$link);
}
mysql_query('COMMIT', $link);
$e = microtime(true);
echo $e - $s;
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
60. Insert Performance
• This time around it only takes 0.0028
seconds compared to the previous 0.0165
seconds. That’s a pretty huge improvement!
• You can read more about this on the
Doctrine Blog
http://www.doctrine-project.org/blog/transactions-and-performance
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
61. Doctrine Query Language
• DQL parser completely re-written from
scratch
• ...DQL is parsed by a top down recursive
descent parser that constructs an AST
(abstract syntax tree).
• ...The AST is used to generate the SQL to
execute for your DBMS
http://www.doctrine-project.org/documentation/manual/2_0/en/dql-doctrine-query-language
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
62. Doctrine Query Language
• Here is an example DQL query
$q = $em->createQuery('select u from MyProjectEntitiesUser u');
$users = $q->execute();
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
63. Doctrine Query Language
• Here is that same DQL query using the
QueryBuilder API
$qb = $em->createQueryBuilder()
->select('u')
->from('MyProjectEntitiesUser', 'u');
$q = $qb->getQuery();
$users = $q->execute();
http://www.doctrine-project.org/documentation/manual/2_0/en/query-builder
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
64. Doctrine Query Builder
• QueryBuilder API is the same as
Doctrine_Query API in Doctrine 1
• Query building and query execution are
separated
• True builder pattern used
• QueryBuilder is used to build instances of
Query
• You don’t execute a QueryBuilder, you get
the built Query instance from the
QueryBuilder and execute it
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
65. Cache Drivers
• Public interface of all cache drivers
• fetch($id) - Fetches an entry from the
cache.
• contains($id) - Test if an entry exists in the
cache.
• save($id, $data, $lifeTime = false) - Puts
data into the cache.
• delete($id) - Deletes a cache entry.
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
66. Cache Drivers
• Wrap existing Symfony, ZF, etc. cache driver
instances with the Doctrine interface
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
67. Cache Drivers
• deleteByRegex($regex) - Deletes cache
entries where the key matches a regular
expression
• deleteByPrefix($prefix) - Deletes cache
entries where the key matches a prefix.
• deleteBySuffix($suffix) - Deletes cache
entries where the key matches a suffix.
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
68. Cache Drivers
• Each driver extends the AbstractCache class
which defines a few abstract protected
methods that each of the drivers must
implement to do the actual work
• _doFetch($id)
• _doContains($id)
• _doSave($id, $data, $lifeTime = false)
• _doDelete($id)
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
69. APC Cache Driver
• To use the APC cache driver you must have
it compiled and enabled in your php.ini
$cacheDriver = new DoctrineCommonCacheApcCache();
$cacheDriver->save('cache_id', 'my_data');
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
70. Memcache Cache Driver
• To use the memcache cache driver you
must have it compiled and enabled in your
php.ini
$memcache = new Memcache();
$memcache->connect('memcache_host', 11211);
$cacheDriver = new DoctrineCommonCacheMemcacheCache();
$cacheDriver->setMemcache($memcache);
$cacheDriver->save('cache_id', 'my_data');
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
71. Xcache Cache Driver
• To use the xcache cache driver you must
have it compiled and enabled in your
php.ini
$cacheDriver = new DoctrineCommonCacheXcacheCache();
$cacheDriver->save('cache_id', 'my_data');
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
72. Result Cache
• First you need to configure the result cache
$cacheDriver = new DoctrineCommonCacheApcCache();
$config->setResultCacheImpl($cacheDriver);
• Then you can configure each query to use
the result cache or not.
$query = $em->createQuery('select u from EntitiesUser u');
$query->useResultCache(true, 3600, 'my_query_name');
• Executing this query the first time would
populate a cache entry in $cacheDriver
named my_query_name
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
73. Result Cache
• Now you can clear the cache for that query
by using the delete() method of the cache
driver
$cacheDriver->delete('my_query_name');
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
74. Command Line Interface
• Re-written command line interface to help
developing with Doctrine
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
75. dbal:run-sql
• Execute a manually written SQL statement
• Execute multiple SQL statements from a file
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
76. orm:clear-cache
• Clear all query, result and metadata cache
• Clear only query cache
• Clear only result cache
• Clear only metadata cache
• Clear a single queries result cache
• Clear keys that match regular expression
• Clear keys that match a prefix
• Clear keys that match a suffix
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
77. orm:convert-mapping
• Convert metadata information between
formats
• Convert metadata information from an
existing database to any supported format
(yml, xml, annotations, etc.)
• Convert mapping information from xml to
yml or vice versa
• Generate PHP classes from mapping
information with mutators and accessors
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
78. orm:ensure-production-settings
• Verify that Doctrine is properly configured
for a production environment.
• Throws an exception when environment
does not meet the production requirements
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
79. orm:generate-proxies
• Generate the proxy classes for entity
classes.
• A proxy object is an object that is put in
place or used instead of the "real" object. A
proxy object can add behavior to the object
being proxied without that object being
aware of it. In Doctrine 2, proxy objects are
used to realize several features but mainly
for transparent lazy-loading.
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
80. orm:run-dql
• Execute a DQL query from the command
line
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
81. orm:schema-tool
• Drop, create and update your database
schema.
• --create option creates the initial tables for
your schema
• --drop option drops the the tables for your
schema
• --update option compares your local
schema information to the database and
updates it accordingly
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
82. Inheritance
• Doctrine 2 fully supports inheritance. We
allow the following types of inheritance:
• ...Mapped Superclasses
• ...Single Table Inheritance
• ...Class Table Inheritance
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
84. Mapped Superclasses
CREATE TABLE EntitySubClass (mapped1 INTEGER NOT NULL,
mapped2 TEXT NOT NULL,
id INTEGER NOT NULL,
name TEXT NOT NULL,
related1_id INTEGER DEFAULT NULL,
PRIMARY KEY(id))
http://www.doctrine-project.org/documentation/manual/2_0/en/inheritance-mapping#mapped-superclasses
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
85. Single Table Inheritance
/**
* @Entity
* @InheritanceType("SINGLE_TABLE")
* @DiscriminatorColumn(name="discr", type="string")
* @DiscriminatorMap({"person" = "Person", "employee" = "Employee"})
*/
class Person
{
// ...
}
/**
* @Entity
*/
class Employee extends Person
{
// ...
}
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
86. Single Table Inheritance
• All entities share one table.
• To distinguish which row represents which
type in the hierarchy a so-called
discriminator column is used.
http://www.doctrine-project.org/documentation/manual/2_0/en/inheritance-mapping#single-table-inheritance
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
87. Class Table Inheritance
namespace MyProjectModel;
/**
* @Entity
* @InheritanceType("JOINED")
* @DiscriminatorColumn(name="discr", type="string")
* @DiscriminatorMap({"person" = "Person", "employee" = "Employee"})
*/
class Person
{
// ...
}
/** @Entity */
class Employee extends Person
{
// ...
}
http://www.doctrine-project.org/documentation/manual/2_0/en/inheritance-mapping#single-table-inheritance
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
88. Class Table Inheritance
• Each class in a hierarchy is mapped to
several tables: its own table and the tables
of all parent classes.
• The table of a child class is linked to the
table of a parent class through a foreign
key constraint.
• A discriminator column is used in the
topmost table of the hierarchy because this
is the easiest way to achieve polymorphic
queries.
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
89. Batch Processing
• Doctrine 2 offers the ability to do some
batch processing by taking advantage of
the transactional write-behind behavior of
an EntityManager
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
90. Bulk Inserts
• Insert 10000 objects with a batch size of 20
$batchSize = 20;
for ($i = 1; $i <= 10000; ++$i) {
$user = new CmsUser;
$user->setStatus('user');
$user->setUsername('user' . $i);
$user->setName('Mr.Smith-' . $i);
$em->persist($user);
if ($i % $batchSize == 0) {
$em->flush();
$em->clear(); // Detaches all objects from Doctrine!
}
}
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
91. Bulk Update
• Bulk update with DQL
$q = $em->createQuery('update MyProjectModelManager m set
m.salary = m.salary * 0.9');
$numUpdated = $q->execute();
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
92. Bulk Update
• Bulk update by iterating over the results
using the Query::iterate() method to avoid
loading everything into memory at once
$batchSize = 20;
$i = 0;
$q = $em->createQuery('select u from MyProjectModelUser u');
$iterableResult = $q->iterate();
foreach($iterableResult AS $row) {
$user = $row[0];
$user->increaseCredit();
$user->calculateNewBonuses();
if (($i % $batchSize) == 0) {
$em->flush(); // Executes all updates.
$em->clear(); // Detaches all objects from Doctrine!
}
++$i;
}
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
93. Bulk Delete
• Bulk delete with DQL
$q = $em->createQuery('delete from MyProjectModelManager m
where m.salary > 100000');
$numDeleted = $q->execute();
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
94. Bulk Delete
• Just like the bulk updates you can iterate
over a query to avoid loading everything
into memory all at once.
$batchSize = 20;
$i = 0;
$q = $em->createQuery('select u from MyProjectModelUser u');
$iterableResult = $q->iterate();
while (($row = $iterableResult->next()) !== false) {
$em->remove($row[0]);
if (($i % $batchSize) == 0) {
$em->flush(); // Executes all deletions.
$em->clear(); // Detaches all objects from Doctrine!
}
++$i;
}
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
95. NativeQuery + ResultSetMapping
• The NativeQuery class is used to execute
raw SQL queries
• The ResultSetMapping class is used to
define how to hydrate the results of that
query
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
96. NativeQuery + ResultSetMapping
• Here is a simple example
$rsm = new ResultSetMapping;
$rsm->addEntityResult('DoctrineTestsModelsCMSCmsUser', 'u');
$rsm->addFieldResult('u', 'id', 'id');
$rsm->addFieldResult('u', 'name', 'name');
$query = $this->_em->createNativeQuery(
'SELECT id, name FROM cms_users WHERE username = ?',
$rsm
);
$query->setParameter(1, 'romanb');
$users = $query->getResult();
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
97. NativeQuery + ResultSetMapping
• The result of $users would look like
array(
[0] => User (Object)
)
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
98. NativeQuery + ResultSetMapping
• This means you will always be able to
fallback to the power of raw SQL without
losing the ability to hydrate the data to your
entities
Doctrine 2 www.doctrine-project.org www.sensiolabs.com
99. Questions?
Jonathan H. Wage
jonathan.wage@sensio.com
+1 415 992 5468
sensiolabs.com | doctrine-project.org | sympalphp.org | jwage.com
You should follow me on http://www.twitter.com/jwage for updates about Doctrine
You can contact Jonathan about Doctrine and Open-Source or for
training, consulting, application development, or business related
questions at jonathan.wage@sensio.com
Doctrine 2 www.doctrine-project.org www.sensiolabs.com