1000 search results

Using a Base Email Template

…data is fresh... with recent article created dates. Run: php bin/console doctrine:fixtures:load This should add enough users and articles that about 1-2 authors will be subscribed to the newsletter and have recent articles. Try that command: Ha! It didn't explode…

8:54
Unit Testing our Emails

…a general rule, I like to mock services but manually instantiate simple "data" objects, like Doctrine entities. The reason is that these classes don't have dependencies and it's usually dead-simple to put whatever data you need on them. Basically, it's easier…

7:56
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
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
Spotting Heavy Object Instantiation

…to instantiate Doctrine's EntityManager object. I know, we don't often think about how much time or how much memory it takes to instantiate an object, but it can sometimes be a problem. The next function call is for the instantiation of Doctrine's…

6:06
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
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
Auto-set the Owner: Entity Listener

…Don't worry, I'll tell you which one I would use and why. Our options include an API Platform event listener - a topic we haven't talked about yet - an API Platform data persister or a Doctrine event listener. The first two - an API…

9:46
Query Extension: Auto-Filter a Collection

…soon as we create a class that implements this interface, every single time that API Platform makes a Doctrine query for a collection of results, like a collection of users or a collection of cheese listings, it will call this method and pass us a…

9:37
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
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
Bulletproof MongoDB

…through what the PHP driver does when you use it. So we start with a connection string, which is similar to if use Doctrine with a relational database there's a DSN. This is very similar. We have specifications that tell us how to parse…

43:33
Linking Symfony deps to your Local Copy

…to use annotations with the validator, you need to install the annotations library. Stop the web server and run: composer require annotations This installs sensio/framework-extra-bundle... we only technically need to install doctrine/annotations. But, that's ok. Restart the built-in web…

6:48
Triaging a Bug Issue

…the user says that he got an error when trying to serialize a Doctrine QueryBuilder with the web profiler: something about not being able to serialize a PDO instance. The web profiler works by collecting a bunch of information about the request and serializing it…

8:36
A bit of Security Cleanup

…with our User class so we get auto-completion. Back down in our method, we can say $this->getUser()->getArticles()->isEmpty(), which is a method on Doctrine's Collection object. So, if we don't have ROLE_ADMIN_ARTICLE and we are not the author…

7:02
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
EntityType: Drop-downs from the Database

…Anyways, we'll see in a minute how we can control what's displayed here. So... great first step! It looks like the form guessing system correctly sees the Doctrine relation to the User entity and configured the EntityType for us. Go team! But now…

7:33
HTML5 & "Sanity" Validation

…can be kind of annoying & surprising. However, when you bind your form to an entity class, the form field guessing system uses the nullable Doctrine option to choose the correct required option value for you. In fact, if we look at the textarea field... yep…

6:19
The Edit Form

…Go to /article/1/edit. Dang - I don't have an article with id Let's go find a real id. In your terminal, run: php bin/console doctrine:query:sql 'SELECT * FROM article' Perfect! Let's us id 26. Hello, completely pre-filled form…

7:18
Agree to Terms Database Field

…directory, open that file and... yep! It adds the one field. Run it with: php bin/console doctrine:migrations:migrate Oh no! Things are not happy. We have existing users in the database! When we suddenly create a new field that is NOT NULL, MySQL…

6:03