1000 search results

Profiling Command Line scripts

…flush() to, sort of, "clear" Doctrine's memory of the BigFootSighting object you just finished... so that it doesn't check it for changes when we call flush() during the next time through the loop: The point is: like with everything, make your code do…

6:33
Comparisons: Validate Performance Changes, Find Side Effects

…ll see this later - not every change we'll do in this tutorial will prove to be a good one. Next: Blackfire has a deep understanding of PHP, database queries, Redis calls and even libraries like Symfony, Doctrine, Magento, Composer, eZ platform, Wordpress and others…

3:56
Finding Issues via the Call Graph

…That's the last function before it jumps into Doctrine. So the problem in our code is something around this getUserActivityText() stuff. Let's open up this template: main/sighting_show.html.twig - at templates/main/sighting_show.html.twig. If you look at the…

6:50
Recommendations

…on your radar. There's also a recommendation that Doctrine annotation metadata should be cached in production. Honestly... I'm not sure why that's there - Symfony apps come with a config/packages/prod/doctrine.yaml file that takes care of caching these when you…

6:25
Wall Time, Exclusive Time & Other Wonders

…whatever that is. If you use Doctrine, you might know what this is - but let's pretend we have no idea. Before we dive further into the root cause behind this slow function, the other way to order the calls is by the number of…

7:47
Deleting Files

…problem: the file might get deleted, but then the row stays because of a temporary connection error to the database. If you're worried about this, use a Doctrine transaction to wrap all of this logic. If the file was successfully deleted, commit the transaction…

8:58
Dummies

…object - an object that does work, but doesn't hold much data, like DinosaurFactory, Doctrine's EntityManager or a class that sends emails, mock it. That's because these are usually difficult to instantiate and often have side effects, like talking to the database or…

6:24
Let: The Setup Function

…If you're a Doctrine user, this will look familiar. But, no, I'm not recommending that you actually create or move the EntityManagerInterface into your app like this. We're adding this interface as a convenient way to "pretend" like Doctrine exists in our…

7:08
Buzzwords! Specification & Examples

…bin/phpspec describe App/Entity/Dinosaur I could have chosen any namespace starting with App - that's up to how you want to organize your code. But, if you're used to Doctrine in Symfony, this will feel familiar. Ok! One new file: DinosaurSpec.php…

7:47
Fetching Relations

…inside the Question entity, the $answers property will not be a true array of Answer objects. Nope, it will be some sort of Doctrine collection object. It may be an ArrayCollection object or this PersistentCollection object... just depending on the situation. It doesn't really…

6:58
Handling ManyToMany in Foundry

…maybe you see it... but let's try it anyways. Spin over and reload the fixtures: symfony console doctrine:fixtures:load Awesome. And now check the database. I'll first say: symfony console doctrine:query:sql 'SELECT * FROM tag' Yep! We do have 100 tags…

4:01
When a Migration Falls Apart

…ve fixed the migration, how can we run it again? Let's try the obvious: symfony console doctrine:migrations:migrate It fails again! But for a different reason: dropping the foreign key failed because that's already gone. Here's the problem. When we first…

6:23
Saving Items in a ManyToMany Relation

… Let's try this thing! Reload the fixtures: symfony console doctrine:fixtures:load And... no errors! Check the database: symfony console doctrine:query:sql 'SELECT * FROM tag' No surprise: we have two tags in this table. Now SELECT * FROM question_tag - the join table. And…

6:36
QuestionTag Fixtures & DateTimeImmutable with Faker

…We can see this. Open up the fixtures class and say QuestionTagFactory::createMany(10). I'm going to put a return statement here because some of the code below is currently broken. Let's try this: symfony console doctrine:fixtures:load And... it fails! But.…

4:07
Adding & Checking the User's Password

…yes! It looks perfect: ALTER TABLE user ADD password: Close that, go back to your terminal, and migrate: php bin/console doctrine:migrations:migrate Awesome! Go open the User class. Yep - we now have a password field: And all the way at the bottom, a…

8:27
Bind Your Form to a Class

…bind your form to a class, a special system - called the "form type guessing" system - tries to guess the proper "type" for each field. It notices that the $content property on Article is a longer text Doctrine type. And so, it basically says: Hey peeps…

7:32
Void Types & Refactoring an Entire Class

…return type to the class you know you're returning... or use the more flexible interface. But actually, for Doctrine collections, you must use Collection. Depending on the situation, this property might be an ArrayCollection or a PersistentCollection... both of which implement the Collection interface…

7:06
Fixtures: Dummy Data Rocks

…not available in the prod environment. That's fine for us - this is a development tool - and it keeps the prod environment a little smaller. Anyways, this bundle gives us a new console command - doctrine:fixtures:load. When we run that, it'll look for …

3:45
Querying for a Single Entity for a "Show" Page

…is that this returns a VinylMix object. Unless you do something custom, Doctrine always gives us back either a single object or an array of objects, depending on which method you call. Now that we have the VinylMix object, let's render a template and…

8:55
Recipe Upgrades with recipes:update

…the recipe relate to the config files, and I bet you can see what's happening. It deleted two environment-specific config files and updated the main one. Hmm. Open config/packages/doctrine.yaml. Sure enough, at the bottom, we see when@test and when…

6:13