1000 search results

Flex Extras

…more going on. Find your composer.json file and make sure the version constraint is ^3.0. Then, run: composer update doctrine/doctrine-fixtures-bundle Version 3 of this bundle is all new... but not in a "broke everything" kind of way. Before, fixture classes…

6:31
Bye Bye AppBundle

…But, the fix is easy: Find all AppBundle and replace with App. Done! There is one last thing we need to undo: in config/packages/doctrine.yaml. Remove the AppBundle mapping we added. So, what other AppBundle things haven't been updated yet? It's…

7:51
Final config/ Migration

…We can also delete config_prod.yml. Oh, by the way, if you have some doctrine caching config in config_prod.yml, I would recommend not migrating it. The DoctrineBundle recipe gives you prod configuration that is great for production out-of-the-box. Booya…

7:25
Priming cache.app

…production. Add framework, cache and app set to cache.adapter.redis: cache.adapter.redis is the id of a service that Symfony automatically makes available. You can also use cache.adapter.filesystem - which is the default - doctrine, apcu, memcached or create your own service. If…

7:00
Safe Migrations

…back a deploy before. But, let's update it to be safe: SET image = poster, and then ALTER TABLE to drop poster: This is a safe migration. First, try it locally: ./bin/console doctrine:migrations:migrate Perfect! And now... deploy! Right? No! Stop that…

7:10
Autowiring Deprecations

…we can create an alias. Copy the Doctrine\ORM\EntityManager class name. Then, find your editor and open up services.yml. Add the alias: Doctrine\ORM\EntityManager aliased to @, and then copy the target service id: @doctrine.orm.default_entity_manager: We have full control…

5:36
Autowiring Controller Arguments

…container directly! We know the fix: type-hint a new argument with LoginFormAuthenticator $authenticator and use that below: Almost done! The app.doctrine.hash_password_listener service isn't being used anywhere, and neither is app.form.help_form_extension. And... that's it! At…

6:20
_defaults, autowire & autoconfigure

…it for you. This works for many - but not all tags. It does not work for doctrine.event_subscriber or form.type_extension: Because it has an extended_type tag option... which the system can't guess for you. When you're developing a feature…

5:20
Adding to a Collection: Cascade Persist

…operations for GenusScientist. Umm, what? Here's what's going on: when we persist the Genus, Doctrine sees the new GenusScientist on the genusScientists array... and notices that we have not called persist on it. This error basically says: Yo! You told me that you…

6:04
Collection Delete & allow_delete

…submit, the final array will have three GenusScientist objects in it, instead of four. Ready? Submit! Hmm, no error... but it still doesn't work. Why not? Hint: we already know the answer... and it relates to Doctrine's inverse relationships. Let's fix it.

4:49
Saving the Inverse Side of a ManyToMany

… What's going on!? This is the moment where someone who doesn't know what we're about to learn, starts to hate Doctrine relations. Earlier, we talked about how every relationship has two sides. You can start with a Genus and talk about the…

4:03
EntityType Checkboxes with ManyToMany

…to change the genusScientists property, that's what we should call the field. The type will be EntityType: This is your go-to field type whenever you're working on a field that is mapped as any of the Doctrine relations. We used it earlier…

5:39
Hooking up the Scientist Removal JavaScript

…Mixed in with AJAX call for notes is our DELETE call. Click the little sha, then go to the Doctrine tab. Ooh, look at this: DELETE FROM genus_scientist WHERE genus_id = 11 AND user_id = 11 Gosh darn it that's nice…

2:50
ManyToMany Relationship

…thing is that it will hold the array of User objects that are linked to this Genus: Above, add the annotation: @ORM\ManyToMany with targetEntity="User". Finally, whenever you have a Doctrine relationship where your property is an array of items, so, ManyToMany and OneToMany…

5:18
JoinColumn & Relations in Fixtures

…Alice will now look at the 10 Genus objects matching this pattern and select a random one each time. Reload the fixtures: It's alive! Check out the results again with doctrine:query:sql: Every single one has a random genus. Do you love it…

3:15
Tagging Scenarios in order to Load Fixtures

…with no var_dump(). Perfect! One way to execute the fixture is by running the doctrine:fixtures:load command. I use a different method that gives me more control. Add $loader = new ContainerAwareLoader() and pass it the container: Now, point to the exact fixtures…

5:16
When *I* do Something: Handling the Current User

…object which will be the author for those products: Now, add an if statement that says, if $author is passed then, $product->setAuthor(): I already have that relationship setup with in Doctrine. Great! In thereAreProducts(), change the body of this function to $this->createProducts($count)…

4:10
The SymfonyExtension & Clearing Data Between Scenarios

…use hooks. Create a new public function clearData(): Clearing data now is pretty easy, since we have access to the entity manager via self::container->get('doctrine')->getManager();: Now we can issue DELETE queries on the two entities that we care about so far: product…

5:13
Controlling the Database

…so we can say $user = new User(). Then set the username and the "plainPassword": I have a Doctrine listener already setup that will encode the password automatically. Which is good: it's well-known that raptors can smell un-encoded passwords... In this app…

4:24
PHP 8.4 & Recipe Updates

…we have a bunch to update. We'll go through them one-by-one. Hitting enter will use the first one in the list, doctrine/deprecations. "No file changed...". Hmm, run git status so see what's up. Just the symfony.lock file was modified…

11:21