Chapters
19 Chapters
|
1:23:55
|
This course is still being released! Check back later for more chapters.
Login to bookmark this video
-
Course Code
Subscribe to download the code!
Subscribe to download the code!
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
While this tutorial's code uses Symfony 8, everything discussed works in Symfony 7!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=8.4",
"ext-ctype": "*",
"ext-iconv": "*",
"babdev/pagerfanta-bundle": "^4.6", // v4.6.0
"doctrine/dbal": "^4.4", // 4.4.3
"doctrine/doctrine-bundle": "^3.2", // 3.2.2
"doctrine/doctrine-migrations-bundle": "^3.7", // 3.7.0
"doctrine/orm": "^3.6", // 3.6.6
"knplabs/knp-time-bundle": "^2.5", // 2.5.0
"pagerfanta/doctrine-orm-adapter": "^4.8", // v4.8.0
"php-cs-fixer/shim": "^3.94", // v3.95.2
"phpdocumentor/reflection-docblock": "^5.6", // 5.6.7
"phpstan/phpdoc-parser": "^2.3", // 2.3.2
"stof/doctrine-extensions-bundle": "^1.15", // v1.15.3
"symfony/asset": "8.0.*", // v8.0.8
"symfony/asset-mapper": "8.0.*", // v8.0.11
"symfony/console": "8.0.*", // v8.0.11
"symfony/dotenv": "8.0.*", // v8.0.11
"symfony/flex": "^2.10", // v2.10.0
"symfony/form": "8.0.*", // v8.0.9
"symfony/framework-bundle": "8.0.*", // v8.0.11
"symfony/http-client": "8.0.*", // v8.0.9
"symfony/monolog-bundle": "^4.0", // v4.0.2
"symfony/property-access": "8.0.*", // v8.0.8
"symfony/property-info": "8.0.*", // v8.0.8
"symfony/rate-limiter": "8.0.*", // v8.0.14
"symfony/runtime": "8.0.*", // v8.0.12
"symfony/security-bundle": "8.0.*", // v8.0.12
"symfony/security-csrf": "8.0.*", // v8.0.8
"symfony/serializer": "8.0.*", // v8.0.10
"symfony/stimulus-bundle": "^2.34", // v2.35.0
"symfony/twig-bundle": "8.0.*", // v8.0.8
"symfony/ux-turbo": "^2.34", // v2.35.0
"symfony/validator": "8.0.*", // v8.0.10
"symfony/yaml": "8.0.*", // v8.0.12
"symfonycasts/tailwind-bundle": "^0.12.0", // v0.12.0
"twig/extra-bundle": "^3.24", // v3.24.0
"twig/twig": "^3.24" // v3.26.0
},
"require-dev": {
"symfony/debug-bundle": "8.0.*", // v8.0.8
"symfony/maker-bundle": "^1.67", // v1.67.0
"symfony/stopwatch": "8.0.*", // v8.0.8
"symfony/web-profiler-bundle": "8.0.*", // v8.0.12
"zenstruck/foundry": "^2.9" // v2.10.1
}
}
14 Comments
Not sure what I did wrong (which is typical). I ran
It worked correctly in that it did run src/Story/AppStory and did load the Users. But it dropped the "doctrine_migrations_versions" table.
Before loading the fixtures:
And now after loading the fixtures:
That doesn't seem right.
What am I doing wrong?
Some notes on my app.
[ ] Entities are not stored under src/Entity but rather src/Data/Entity - that might be the problem. However, load-fixtures does create all the entities tables.
[ ] doctrine.yaml has orm: mappings:
[ ] make:migration has not problem finding the Entities
[ ] doctrine:migrations:migrate works fine.
Also doctrine:fixtures:load does not drop the "doctrine_migrations_versions" table.
However, it does not use AppStory, so no Users were loaded.
I've followed all the steps in this chapter, but there's a problem: the only user created isn't being loaded into the User table. When I run
symfony console dbal:run-sql 'select * from user', I get:[OK] The query yielded an empty result set.If I use the DB Browser for SQLite tool and inspect the User table, it is indeed empty.
@Brontie
The chapter’s fixture user is created by Foundry, so an empty
usertable usually means the fixtures story never ran, not that Doctrine is broken. Run the story loader explicitly soAppStoryinsertspicard@enterprise.spaceinto the database:If the table is still empty after that, make sure you already ran the migration that creates the
usertable, because Foundry can’t insert into a table that doesn’t exist yet. A common gotcha here is checking the SQLite file in one place while Symfony is using a different database path, so verify you’re looking at the samevar/data.dbyour app is actually configured to use.Sources:
Hey @giorgiocba
This may sound silly, but did you load the fixtures?
symfony console foundry:load-fixturesIf you did, could you do it again and see if there were any errors or warnings?
Another thing to check is whether you're using Docker for the database and whether you have it installed locally. It may be the case that the CLI is using the Docker instance, but the web isn't.
Cheers!
What could have happened?
"Houston: no signs of life"
Start the conversation!