Priming cache.app
... automatically makes
available. You can also use cache.adapter.filesystem - which is the default -
doctrine, apcu, memcached or create your own service. If you need to configure
Redis, use the default_redis_provider key under app ...
Safe Migrations
...
./bin/console doctrine:migrations:diff
Go check it out in app/DoctrineMigrations. Wow... it's actually perfect:
ALTER TABLE video CHANGE image (to) poster...
Doctrine is smart ...
Void Types Refactoring an Entire Class
... 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 ...
Using a Test Database
... 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 ...
Weird Endpoint The tagline as a Resource
... 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 ...
Pagerfanta Pagination
... () - 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 object, call setMaxPerPage() and pass it 10. And then ...
Adding to a Collection Cascade Persist
... Genus.genusScientists that
was not configured to cascade persist operations for GenusScientist.
Umm, what? Here's what's going on: when we persist the Genus, Doctrine sees the
new GenusScientist on the genusScientists array... and ...
Tracking Cancelations in our Database
... () 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 to the account page, then press
the new "Cancel Subscription" button. Ok ...
Give the User a Subscription in our Database
... $stripeSubscription->id:
Booya!
And, time to save this to the database! Since we're using Doctrine in Symfony, we
need the EntityManager object to do this. I'll use dependency injection: add an
EntityManager argument to the ...
After-dinner Mint
... it and set a nullable=true option in the Doctrine metadata. Don’t
worry about updating your schema - this change is just temporary:
// src/Yoda/UserBundle/Entity/User.php
// ...
/**
@ORM\Column(type="string", length ...
Server-Side Validation
... \Doctrine\Validator\Constraints\UniqueEntity;
/**
@ORM\Table(name="yoda_user")
@ORM\Entity(repositoryClass="Yoda\UserBundle\Entity\UserRepository")
@UniqueEntity(fields="username", message="That username is taken ...
Code Generation FTW
... need a CRUD for the Event entity.
Want to use Doctrine to generate a CRUD? Yea, there's a console command for
that doctrine:generate:crud:
php app/console doctrine:generate:crud
This ...
Making an Argument Available to All Controllers
... object
via Doctrine with that id, and then adds a new request attribute called post
that’s set to that object:
// Summarized version of ParamConverterListener
public function onKernelController(FilterControllerEvent $event ...
Deployment
...
There’s a library called Doctrine Migrations that helps do this safely.
Clear your production cache:
php app/console cache:clear --env=prod
Dump your Assetic assets:
php app/console assetic:dump --env=prod
That’s it ...
Twig Extensions and Dependency Injection Tags
... them too often, but they’re
key to unlocking really powerful features.
A very important tag is kernel.event_listener, which allows you to register
“hooks” inside Symfony at various stages of the request lifecycle. That topic
is for another screencast, but we’ll cover a very similar subject next: Doctrine
events.
... /php-code-coverage (5.3.2): Downloading (100%)
- Installing sebastian/exporter (3.1.0): Downloading (100%)
- Installing doctrine/instantiator (1.0.5): Downloading (100%)
- Installing phpunit/phpunit-mock-objects ...
Hi
Two questions regarding doctrine:
1) when I want to save to the db the images from a multi-select form field, I can't save them using doctrine's way. Example:
```
/**
* Creates a new product entity.
*
* @Route ...
... translations for the same language, but for different countries (e.g. British vs UK English).
B) Translating your data inside Doctrine is an entirely different task (and you should make sure you need this - it's a lot of extra ...
... point, contain the correct
// array of Tag objects that was selected
// you can just save the Post to Doctrine now
$em = $this->getDoctrine()->getManager();
$em->persist($post ...
... "
hydra:title
:
"An error occurred"
status
:
500
title
:
"An error occurred"
trace
:
[{file: "/app/vendor/doctrine/dbal/src/Connection.php", line: 1051, function: "new",…},…]
```
Service
```
#[AsController ...
2725
Doctrine
Filter Results