1000 search results

Webhook: Subscription Canceled

…be canceled. Below, really simple, say $subscription->cancel(). Then, use the Doctrine entity manager to save this to the database: Mind blown! Back in the controller, call this! Above the switch statement, add a $subscriptionHelper variable set to $this->get('subscription_helper'): Finally, call $subscriptionHelper…

5:08
Tracking Cancelations in our Database

…month: Cool! To deactivate the subscription in the controller, it's as easy as saying $subscription->deactivateSubscription() and then saving it to the database with the standard persist() and flush() Doctrine code: And that should do it! Let's give this guy a try. Go…

7:57
We <3 Creating Stripe Customers

…our user record, say $user->setStripeCustomerId($customer->id): Then, I'll use Doctrine to run the UPDATE query to the database: If you're not using Doctrine, just make sure to update the user record in the database however you want. Now, add the else…

4:37
Stripe Customers + Our Users

…getters and setters for the new property: Now that our PHP code is updated, we need to actually add the new column to our table. Since this project uses Doctrine migrations, open a new tab and run: All that did was create a new file…

2:55
Adding a Cache Service

…it entirely on our own. First, we need to configure the bundle. To see what keys it has, find the terminal and run: The list has a new entry: doctrine_cache. Re-run the command with this: Nice! There's our huge configuration example! Ok…

3:27
Users Need Passwords (plainPassword)

…plain-text password on the User and encode it automatically via a Doctrine listener when it saves. To do that, add a new property on User called plainPassword. But wait! Don't persist this with Doctrine: we will of course never store plain-text passwords:…

3:32
The UserInterface Methods (Keep some Blank!)

…feel ok leaving these blank. So in our application, we want to store users in the database. So let's set this class up with Doctrine. Copy the use statement from SubFamily and paste it here: Next, I'll put my cursor inside the class…

4:19
The All-Important User Class

…somewhere else - like a central authentication server. In those cases, you will still have a User class, you just won't store it with Doctrine. More on that as we go along. Ok, we've got the empty user class: let's fill it in!

4:22
Custom Query in EntityType

…So, if you pass a query_builder option and set it to an anonymous function, Doctrine will pass that the entity repository for this specific entity. All we need to do is create whatever query builder we want and return it. In the form, add…

3:30
Binding Forms to Objects: data_class

…Look at this! A free drop-down with almost no work. It also noticed that isPublished should be a checkbox because that's a boolean field in Doctrine: And since firstDiscoveredAt is a date, it rendered it with year-month-day drop-down boxes. Now…

4:44
Process that Form!

…to use that associative array to create a new Genus object, populate it with the data, and save it via Doctrine. But, it would be awesomesauce if the form framework could do our job for us. I mean, use the data to automatically create the…

2:46
Weird Endpoint: The tagline as a Resource?

…the route should be /api/programmers/{nickname}/tagline. To be super hip, add an @Method annotation: we know this should only match PUT requests: Like before, type-hint the Programmer argument so that Doctrine will query for it for us, using the nickname value. And…

5:47
Adding Links via Annotations

…a few minutes! To create this cool system, we need to understand a bit about annotations. Every annotation - like Table or Entity from Doctrine - has a class behind it. That means we need a Link class. Create a new directory called Annotation. Inside add a…

6:22
Filtering / Searching

…things by returning $qb at the bottom: If you were using something like Elastic Search, then you wouldn't be making this query through Doctrine: you'd be doing it through elastic search itself. But the idea is the same: prepare some search for Elastic…

4:14
Pagerfanta Pagination

… This is all we need to use Pagerfanta. In the controller, start with $adapter = new DoctrineORMAdapter() - since we're using Doctrine - and pass it the query builder. Next, create a $pagerfanta variable set to new Pagerfanta() and pass it the adapter. On the Pagerfanta…

6:29
Using a Test Database

…as the default. Once we do that, we can setup the test environment to use a different database name. Open config.yml and copy the doctrine configuration. Paste it into config_test.yml to override the original. All we really want to change is dbname…

6:52
Selecting Specific Fields

…s an awesome error: This is what it looks like when you mess up your DQL. Doctrine does a really good job of lexing and parsing the DQL you give it, so when you make a mistake, it'll give you a pretty detailed error…

5:04
Joins and addSelect Reduce Queries

…That's different from SQL, where selecting all the fields from a joined table will give you more fields in your result. Here, addSelect() just tells Doctrine to fetch the FortuneCookie data, but store it internally. Later, when we access the FortuneCookies for a Category…

6:03
Making Fixtures Awesome with Alice

…files, and the same DoctrineFixturesBundle that we were talking about before. This is a really nice combination because it's going to mean that we can still run our normal php app/console doctrine:fixtures:load. But after that, instead of writing raw PHP code…

12:23
HATEOAS Loves Routers

…and it doesn't! I messed up some syntax. Anytime you see the Doctrine\Common\Annotations T_CLOSE_PARENTHESIS type of thing, this is a syntax error in your annotation. I'm missing a comma between my arguments. Let's try that one more time…

3:12