1000 search results

Docker & Environment Variables

…cool. By the way, if you want to see all the environment variables the Symfony binary is setting, you can run: symfony var:export --multiline But the most important one by far is DATABASE_URL. Ok: Doctrine is configured! Next, let's create the database…

3:43
docker-compose & Exposed Ports

…Thanks to some magic between Docker and the Symfony binary, this is going to be super easy. To start, remember when the Doctrine recipe asked us if we wanted Docker configuration? Because we said yes, the recipe gave us docker-compose.yml and docker-compose…

6:53
Collection Criteria for Custom Relation Queries

… Fortunately, no! These Doctrine Collection objects have a few tricks up their sleeves, including a special "criteria" system for just this situation. It allows us to describe how we want to filter the answers and then it uses that when it queries! Remove the filter…

6:33
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
Resetting the Database Between Tests

…using random data and linking objects to each other. It was the inspiration behind a fixture class that we created and used in our Symfony Doctrine tutorial. The recipe creates a fixtures/ directory for the YAML files and a new command for loading that data…

4:51
API Debugging with the Profiler

…the goodies that you expect - cache, performance, security, Doctrine, etc. In addition to the little web debug toolbar AJAX tracker we just saw, there are a few other ways to find the profiler for a specific API request. First, every response has an x-debug…

3:17
Our First ApiResource

…database exists: php bin/console doctrine:database:create And now run make:migration: Let's go check that out to make sure there aren't any surprises: CREATE TABLE cheese_listing... Yea! Looks good! Close that and run: php bin/console doctrine:migrations:migrate Brilliant…

5:37
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
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
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
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
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
Welcome to Symfony!

…requests, responses and templating. Get comfortable with a few extra tools, like Doctrine for dealing with the database and code generation tools. And the real reason you are here, to learn enough best practices and tips to impress your friends at a party. Ready? Let…

2:51
Upgrading to 2.2

…replace the core Symfony libraries, and not any custom lines you may have added. In this case, the doctrine-fixtures-bundle is custom, so I’ll leave it alone: "require": { }, Also, be sure you have the minimum-stability set to alpha. As Stof points out…

3:46
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
Writable Collection via the PropertyAccessor

…into why we can't have a setter, but it relates to the fact that we need to set the owning side of the Doctrine relationship. We talk about this in our Doctrine relations tutorial. The point is, if we were able to just call…

6:29
Quick! Create a DragonTreasure DTO

…And finally, remove the custom DragonTreasureStateProvider and DragonTreasureStateProcessor classes. But we did keep one thing: DragonTreasureIsPublishedExtension. Because the new system will still use the core Doctrine CollectionProvider, this query extension stuff will continue to work and be called. That's just one less thing we…

9:51
Leveraging the Core Processor

…on? We map the UserApi to a new User object and save the new User... which causes Doctrine to assign the new id to that entity object. But we never take that new id and put it back onto our UserApi. To fix this, after…

7:11
Pagination on a Custom Resource

…Second, to return the count of the total number of items. When you use Doctrine, it executes 2 separate queries for this: one to fetch the current page's results with a LIMIT and OFFSET, and a second COUNT query to count every row. Ok…

8:18