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 ...
Upgrading to 2.2
... composer.json
file, being sure to only replace the core Symfony libraries, and not any
custom lines you may have added. In this case, the doctrine-fixtures-bundle
is custom, so I’ll leave it alone:
"require": {
},
Also, be sure ...
Migrations
We created an entity class! But... that's it. The corresponding table does
not yet exist in our database.
Let's think. In theory, Doctrine knows about our entity, all of its properties
and their ORM\Column attributes ...
Attachments with Async Messenger Emails
...
php bin/console app:author-weekly-report:send
Ah! Explosion! Incorrect string value? Wow. Okay. What we're seeing is a real-world
limitation of the doctrine transport: it can't handle binary data. This may change
in ...
Saving Relations
... favorite, always-excited
astronaut commenter: Mike Ferengi:
Then, $comment1->setContent(), and use one of our hardcoded comments:
Perfect! Because we're creating this manually, we need to persist it to Doctrine.
At the ...
2710
Doctrine
Filter Results