1000 search results

Improving Javascript Event Security

…user. Head over to your terminal and run: bin/console doctrine:query:sql "SELECT * FROM user" We have the lsCustomerId set, so let's reset it to NULL with: bin/console doctrine:query:sql "UPDATE user SET lsCustomerId=NULL WHERE id=1" Let's test it out…

4:35
Dynamic Data

… Up here, we can add a description: Add a column to store the LS variant ID on Product. Back in our terminal, run the migration with: bin/console doctrine:migrations:migrate Now, in src/DataFixtures/AppFixtures.php, set our new field to the variant ID…

6:29
Adding new Properties

…anything in my database? The answer is no. I can prove it by running a helpful command: symfony console doctrine:schema:update --dump-sql This is very similar to the make:migration command... but instead of generating a file with the SQL, it just prints…

5:19
The Query Builder

…have... so you might accidentally remove something you added earlier. So, always use andWhere(). Doctrine is smart enough to figure out that, because this is the first WHERE, it doesn't actually need to add the AND. Inside of andWhere(), pass mix.genre =... but…

10:04
Verify Email after Registration

…migration: symfony console make:migration Go check that out and... awesome. It looks exactly like we expect: Run it! symfony console doctrine:migrations:migrate Beautiful! Let's do one more thing related to the database. Inside of src/Factory/UserFactory.php, to make life simpler…

7:57
Foundry Tricks

…Faker again! self::faker()->numberBetween(1, 4) and then true to return this as a string. Let's take this for a test drive! Find your terminal and reload the fixtures with: symfony console doctrine:fixtures:load Go check the homepage and... yea! Oh, but…

7:28
How does the Controller Access the Container?

…And AbstractController implements a special interface called ServiceSubscriberInterface. This is actually something we talk about in one of our Doctrine tutorials. When you implement ServiceSubscriberInterface, it forces you to have a method called getSubscribedServices() where you return an array that says which services you need…

4:14
Events, Events & Events!

…see the Twig templates being executed below it, and even little Doctrine queries happening along the way. The biggest thing I want you to notice is that most of the other lines - both before and after the controller - contain the word Listener, or sometimes Subscriber…

5:10
Mapping Messages to Classes in a Transport Serializer

…I did! I mean, handling messages asynchronously... that's pretty fun stuff. The great thing about Messenger is that it works brilliantly out of the box with a single message bus and the Doctrine transport. Or, you can go crazy: create multiple transports, send things…

4:56
Setup for Uploading Private Article References

…yep! CREATE TABLE article_reference ... with a foreign key back to article. Run that with: php bin/console doctrine:migrations:migrate Before we get back to work, open the Article entity. The command did create the $articleReferences property that allows us to say $article->getArticleReferences()…

5:45
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
Symfony: Keep it Simple with @Route and Templates

… So let’s finish this page. It should be fairly straightforward: we’re going to use Doctrine to query for all the posts and then pass them into a template: /** @Route("/posts") / public function indexAction() { } Now, notice that my template name does not have any…

8:42
Writing an Integrational Test for Webhooks

…an error, but that's expected. No such table in the test environment. Our test is failing because we need to set up a test database. We could do this manually using Doctrine console commands, but let's take advantage of Zenstruck Foundry, which we…

7:16
Implementing the Webhook Consumer

…method, fetch the user with $user = $this->entityManager->getRepository(User::class)->find($userId). Next, if $user doesn't exist, we'll throw new EntityNotFoundException() (choose the one from Doctrine\ORM). For the message write sprintf('User "%s" not found for LemonSqueezy webhook "%s"!', $userId…

8:10
Foundry: Fixtures You'll Love

…But first... let's run blindly forward and use this class! In AppFixtures, delete everything and replace it with VinylMixFactory::createOne(). That's it! Spin over and reload the fixtures with: symfony console doctrine:fixtures:load And... it fails! Boo Expected argument type "DateTime", "null"…

7:20
Updating an Entity

…When you call flush(), Doctrine loops over all of the entity objects that it "knows about" and "saves" them. And that "save" is smart. If Doctrine determines that an entity has not been saved yet, it will execute an INSERT query. But if it's…

5:24
Smarter Entity Methods

…Symfony binary can inject the environment variables. When this finishes, I like to double check the migration to make sure it doesn't contain any surprises. This looks perfect. Execute it with: symfony console doctrine:migrations:migrate Beautiful! But... this did break one little thing…

7:57