Upgrading to Symfony 7
... directly in our composer.json file. Proxies are
something that Doctrine uses behind the scenes to load lazy relationships. Recently,
Symfony added its own version of proxies called "ghost objects". They're spooky
cool. Anyway ...
Final Upgrades Cleanups
... need to update. As I mentioned,
we're going to ignore knplabs/knp-markdown-bundle. But if you have that in a
real project, refactor it to use twig/markdown-extra.
What I'm interested in is doctrine/dbal, which has a new ...
DQL The Query Builder
We just learned that when you ask for a repository, what you actually
get back is a custom class. Well, technically you don't have to have a custom
repository class - and if you don't, Doctrine will just give you an ...
AMQP with RabbitMQ
Open up your .env file and check out the MESSENGER_TRANSPORT_DSN setting.
We've been using the doctrine transport type. The doctrine://default string
says that messages should be stored using Doctrine's default ...
Data Persister Encoding the Plain Password
When an API client makes a POST request to /api/users, we need to be able to run
some code after API Platform deserializes the JSON into a User object, but
before it gets saved to Doctrine. That code will encode the ...
Raw SQL Queries
All this Doctrine entity object stuff and DQL queries are really great.
But if you ever feel overwhelmed with all of this or need write a really
complex query, you can always fall back to using raw SQL. Seriously, this ...
Repository Security
... some Doctrine annotations:
// src/Yoda/UserBundle/Entity/User.php
// ...
/**
@ORM\Column(type="string", length=255)
/
private $email;
Next, generate or write a getter and a setter for the new property.
As a reminder ...
Lean and Mean Dev with PhpStorm for Symfony
... them)!
Tricks for annotations, Doctrine, forms, Twig and more
Refactoring
Live Templates
Fast navigation
Symfony service integration
.... (and always) well-intentioned jokes.
Using RAND or Other Non-Supported Functions
...
Doctrine supports a lot of functions inside DQL, but not everything. Why?
Because Doctrine is designed to work with many different types of databases... and
if only one or some databases support a function like RAND ...
Querying on a Relationship
...
Excellent! And just like before - start with return $this->createQueryBuilder()
with genus_note as a query alias. For now, don't add anything else: finish with
the standard ->getQuery() and ->execute():
Doctrine doesn't ...
Saving a Relationship
Doctrine will create a genus_id integer column for this property and a foreign key to genus.
Use the "Code"->"Generate" menu to generate the getter and setter:
Add a Genus type-hint to setGenus():
Yes, when we call ...
The UserProvider Custom Logic to Load Security Users
... /security.yml
security:
Try logging in now! Ah, a great error:
The Doctrine repository “Yoda\UserBundle\Entity\UserRepository” must implement UserProviderInterface.
The UserProviderInterface¶
Without the property, Doctrine ...
Query for a List of Genuses
... listAction() and give it a route path of /genus:
Remember, everything in Doctrine starts with the all-powerful entity manager. Just
like before, get it with $em = $this->getDoctrine()->getManager():
To make a query, you'll ...
Pagination with Pagerfanta
I want to add one more Doctrine-specific feature to our site: pagination.
Right now, on the homepage, we're rendering every question on the site. That's...
not very realistic. Instead, let's render 5 on each page with ...
Timestampable Failed Migrations
... called timestampable,
and Doctrine Extensions totally has a feature for it.
Start by activating it in the config file: stof_doctrine_extensions.yaml.
Add timestampable: true.
Back at the browser, click into the Doctrine ...
The N+1 Problem EXTRA_LAZY
... we were querying
for too many items and so Doctrine was hydrating too many objects. Is it the
same problem now? And if so, why? Can we optimize it?
Time to put on our profiling detective hats. Let's follow the hot path ...
Transport Do Work Later Async
... the supermarket. Out-of-the box, Messenger supports three: amqp -
which basically means RabbitMQ, but technically means any system that implements
the "AMQP" spec - doctrine and redis. AMQP is the most powerful... but ...
Customizing the User Entity
... array and its Doctrine type is json. This is really cool. Newer
databases - like PostgreSQL and MySQL 5.7 - have a native "JSON" column type
that allows you to store an array of data.
But, if you're using MySQL 5.6 or ...
Saving a ManyToMany Relation Joins
... class name is prefixed by this weird Proxies stuff. When
you see that, ignore it. A "Proxy" is a special class that Doctrine generates
and sometimes wraps around your real entity objects. Doctrine does this so that
it can ...
2725
Doctrine
Filter Results