1000 search results

API Token Authenticator

…in a minute. But first, move over to your terminal: we need to find a valid API key! Run: php bin/console doctrine:query:sql 'SELECT * FROM api_token' Copy one of these long strings, move back to Postman and paste! To see what this…

7:01
ApiToken Entity

…at. And, it creates the foreign key. That looks perfect. Move back and run it! php bin/console doctrine:migrations:migrate So, the question of how these ApiTokens will be created is not something we're going to answer. As we talked about, it's…

7:06
Dynamic Roles

…also need to add ROLE_USER: the getRoles() method will make sure that's returned even if it's not stored in the database: Let's reload those fixtures! php bin/console doctrine:fixtures:load When that finishes, move over and go back to /login…

7:36
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
Using Faker for Seeding Data

…Faker function: $this->faker->numberBetween(5, 100): After these few improvements, let's make sure the system is actually as easy as pie. Find your terminal and run: php bin/console doctrine:fixtures:load No errors and... back on the browser, it works! Of course…

6:29
Updating an Entity

…not needed for updates! When you query Doctrine for an object, it already knows that you want that object to be saved to the database when you call flush(). Doctrine is also smart enough to know that it should update the object, instead of inserting…

7:37
Sluggable & other Wonderful Behaviors

…Now the recipe installs. Thanks to this, we now have a shiny new config/packages/stof_doctrine_extensions.yaml file: This is where we need to enable the extensions we want. We want sluggable. We can use the example in the docs as a guide…

7:24
Fixtures: Seeding Dummy Data!

…one article... but it should work! Try it: find your terminal and run a new console command: php bin/console doctrine:fixtures:load This will ask if you want to continue because - important note! - the command will empty the database first, and then load fresh…

9:34
Updating an Entity with New Fields

…filename: I love it! Close that, run back to your terminal, and migrate! php bin/console doctrine:migrations:migrate Next, we need to make sure these new fields are populated on our dummy articles. Open ArticleAdminController. Oh, but first, remember that, in the Article entity…

9:40
All about Entity Repositories

…at the top of your Article class: This says: when we ask for the Article class's repository, Doctrine should give us an instance of this ArticleRepository class: Oh, and the built-in find*() methods actually come from one of the parent classes of ArticleRepository.…

5:35
Querying for Data!

…hold on, that's important! When you query for something, Doctrine returns objects, not just an associative arrays with data. That's really the whole point of Doctrine! You need to stop thinking about inserting and selecting rows in a database. Instead, think about saving…

9:16
Test Fixtures & Fast Databases!

…step will have already been done for you automatically. We haven't hooked the fixtures into our tests yet, but we can at least try them! Run: php bin/console doctrine:fixtures:load Go check out the browser! Yes! The fixtures gave us 3 enclosures…

7:18
Partial Mocking

…going on? This is subtle: PhpUnit is smart enough to take this one dinosaur object and return it each time growFromSpecification() is called. But to Doctrine, it looks like we're asking it to save the same one Dinosaur object: not three separate dinosaurs. The…

3:59
Tests, Assertions & Coding

…tutorial/ directory with a Dinosaur class inside. Copy that and paste it into the real Entity directory. This is just a simple class with a length property. It does have Doctrine annotations, but that's not important! Sure, we will eventually be able to save…

6:40
My Users don't have a Username!

… No more username! Register as aquanaut4@gmail.com and submit. Check it out in the database: php bin/console doctrine:query:sql 'SELECT * FROM user' There it is! The username is now equal to the email. Oh, and if you're using the profile edit…

2:22
Customizing the Forms

…production anyways, but, you've been warned! Move over to your terminal to generate the migration: php bin/console doctrine:migrations:diff That looks right! Run it: php bin/console doctrine:migrations:migrate New field added! Now, how can we add it to the form?…

6:27
DQL Filtering & Sorting

…a lot of species. Start by adding a list key and a new, awe-inspiring option: dql_filter. For the value, pretend that you're building a query in Doctrine. So, entity.speciedCount >= 50000: The alias will always be entity. Try it! Ten down…

5:19
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
Webhooks: Preventing Replay Attacks

…the AppBundle/Entity directory, create a new PHP Class called StripeEventLog: Give it a few properties: $id, $stripeEventId and a $handledAt date field: Since this project uses Doctrine, I'll add a special use statement on top and then add some annotations, so that this…

5:41
Testing Part 2: Faking the Event Lookup

…that true is false on line 43 It looks like our webhook is not working, because the subscription is still active. But actually, that's not true: Doctrine is tricking us! In reality, the database has been updated to show that the Subscription is canceled…

5:06