Chapters
47 Chapters
|
4:41:51
|
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!
This tutorial also works great for Symfony 6!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"babdev/pagerfanta-bundle": "^3.3", // v3.3.0
"composer/package-versions-deprecated": "^1.11", // 1.11.99.4
"doctrine/annotations": "^1.0", // 1.13.2
"doctrine/doctrine-bundle": "^2.1", // 2.6.3
"doctrine/doctrine-migrations-bundle": "^3.0", // 3.1.1
"doctrine/orm": "^2.7", // 2.10.1
"knplabs/knp-markdown-bundle": "^1.8", // 1.9.0
"knplabs/knp-time-bundle": "^1.11", // v1.16.1
"pagerfanta/doctrine-orm-adapter": "^3.3", // v3.3.0
"pagerfanta/twig": "^3.3", // v3.3.0
"phpdocumentor/reflection-docblock": "^5.2", // 5.2.2
"scheb/2fa-bundle": "^5.12", // v5.12.1
"scheb/2fa-qr-code": "^5.12", // v5.12.1
"scheb/2fa-totp": "^5.12", // v5.12.1
"sensio/framework-extra-bundle": "^6.0", // v6.2.0
"stof/doctrine-extensions-bundle": "^1.4", // v1.6.0
"symfony/asset": "5.3.*", // v5.3.4
"symfony/console": "5.3.*", // v5.3.7
"symfony/dotenv": "5.3.*", // v5.3.8
"symfony/flex": "^1.3.1", // v1.21.6
"symfony/form": "5.3.*", // v5.3.8
"symfony/framework-bundle": "5.3.*", // v5.3.8
"symfony/monolog-bundle": "^3.0", // v3.7.0
"symfony/property-access": "5.3.*", // v5.3.8
"symfony/property-info": "5.3.*", // v5.3.8
"symfony/rate-limiter": "5.3.*", // v5.3.4
"symfony/runtime": "5.3.*", // v5.3.4
"symfony/security-bundle": "5.3.*", // v5.3.8
"symfony/serializer": "5.3.*", // v5.3.8
"symfony/stopwatch": "5.3.*", // v5.3.4
"symfony/twig-bundle": "5.3.*", // v5.3.4
"symfony/ux-chartjs": "^1.3", // v1.3.0
"symfony/validator": "5.3.*", // v5.3.8
"symfony/webpack-encore-bundle": "^1.7", // v1.12.0
"symfony/yaml": "5.3.*", // v5.3.6
"symfonycasts/verify-email-bundle": "^1.5", // v1.5.0
"twig/extra-bundle": "^2.12|^3.0", // v3.3.3
"twig/string-extra": "^3.3", // v3.3.3
"twig/twig": "^2.12|^3.0" // v3.3.3
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.3", // 3.4.0
"symfony/debug-bundle": "5.3.*", // v5.3.4
"symfony/maker-bundle": "^1.15", // v1.34.0
"symfony/var-dumper": "5.3.*", // v5.3.8
"symfony/web-profiler-bundle": "5.3.*", // v5.3.8
"zenstruck/foundry": "^1.1" // v1.13.3
}
}
31 Comments
Hi, the symfony console make:factroy command is not defined, I'm with symfony 6.3.x what can I replace it with ? Thanks
hi, the same here, thanks for your tips!
Hey yannick_boz,
Thanks for letting us know it was helpful for you!
Cheers!
I must install this bundle ->
composer require zenstruck/foundry --devHey @pasquale_pellicani ,
Yep, you need to install that bundle - that's how MakerBundle works, it does not have all possible dependencies and suggests you install specific ones on the go when you're trying to use more features. Good catch!
Cheers!
Hello,
thank you for clarify:)
Hey Mahmut,
You're misleading commands with different purposes:
symfony console make:fixturesis a Symfony console command indeed is used to make a fixtures file, whilecomposer require --dev orm-fixturesis a completely different Composer command that is used to install some package dependencies to your project, in particular it installs some Doctrine bundles, including ORM and fixtures bundle. I.e. if you don't have fixtures bundle in your project - you will not be able to run thatmake:fixturesbundle at all unless instal the bundle that is responsible for fixtures :)Yes, that should be so, you should make sure you have that "factory" installed before being able to create Foundry factories in your project. However, if you already have the foundry installed in your project - than
make:factorywill just work for you, so no need to run thatcomposer require --dev factory. Moreover, if you have Foundry lib already installed - then running this command will do nothing, because nothing new to install for you project, you already have that dependency :)I hope that clarify things for you :)
Cheers!
If you are considering a CRM system with member information, what is the best practice for saving the member's detailed information and relation to other entities?
Should they be added directly to the User Class or should I link them to another entity?
Hey @Mahmoud-A,
Good question! Are the member details shared between users in any way? If not, you could consider a one-to-one relationship but that's probably overkill to start. So I'd add these fields directly to the User and let performance dictate whether another entity is required later.
The CRM's I've worked with have had the concept of a Company, which has Locations (or Branches), then these Locations have Users (or Employees).
Company: McDonalds
Location: Main St., Orlando
User: John Smith
Dear SymfonyCasts,
I am reaching out to report an issue I encountered while utilizing the SymfonyCasts website with a screen reader. Specifically, I am experiencing difficulty in downloading the course code despite multiple attempts to do so.
Outlined below are the steps I followed, provided from the perspective of a screen reader user:
1. Navigated to the top of the website by pressing
CTRL + HOME.2. Focused on the main heading "Customizing the User Class" by pressing
1on the alphanumeric row.3. Moved focus to an unlabeled button preceding the main heading using
SHIFT + TAB.4. Accessed a menu containing four items ("Course Code," "This Video," "Subtitles," and "Course Script") by pressing the
spacebar.5. Attempted to initiate the download by pressing
SPACEBARon the "Course Code" link. Unfortunately, the download did not commence, and the menu closed immediately after the action.6. Additionally, attempting to copy the link of the "Course Code" resulted in "
javascript:void(0)" being copied to the clipboard instead of the expected link.Furthermore, I encountered a similar issue with the course code link in the "Unit Testing With a Byte" course. Despite numerous attempts, I was unable to download the code. Ultimately, I resorted to obtaining the code from GitHub. However, it took a considerable amount of time to know that downloading from GitHub was an available option.
Request: For future courses, please include the GitHub link to the initial course code. This would greatly benefit both screen reader and normal users.
Thanks.
Best regards,
Easwaran Chinraj
Hey @Easwaran_Chinraj
Have you tried to press "Enter" instead of "Spacebar" to download the course code? I managed to download it that way, but I'm on Google Chrome, I'm not sure if that makes a difference
Dear Mollo Khan and leannapelham,
Thank you for dedicating your invaluable time to this matter. I apologize for any inconvenience caused by taking up hours and days of your precious time unintentionally. Unfortunately, I can't fully explain the issue here in the comments section, so I've sent an email to hello@symfonycasts.com with more details.
Cheers,
Easwaran Chinraj
Thank you so much for the very clear report here - we are working to get this resolved!
Hi, I have a problem with fixtures.
when I run:
it works fine the first time, but the second time, it gives me this error:
etc...
It's from a marketingChannel > marketingChannel relation.
I put
die('asdf');in the fixtureload(), but it never reaches this command. It appears to be due to the "purge" command from the fixtures command (when it runs). It appears this command is not intelligently deleting my marketingChannel records.Any idea how I could fix this? I tried orphanRemoval too, but it didn't work.
Hey Cameron,
First, make sure you have valid mapping, run:
to see all green.
Also, maybe try
onDelete="CASCADE"for the relations that cannot be deleted.Cheers!
I got the stack trace (but not the sql query).
It looks like it has to do with the ORMpurger not deleting fixtures correctly.
Where are all these files coming from in the AppFixtures? Did you just create them? I can't find where they are coming from following your tutorials.. they just exist.
Hey Ramon,
Yes, those files are already exist in this course. They come from past tutorials from the fundamental section: https://symfonycasts.com/tracks/symfony5#the-fundamentals - we base every new tutorial on the previous one.
Cheers!
Ah I see! Thanks a lot for the info! :)
Hey,
Maybe silly question but I can't figure out how to display
symfony console doctrine:query:sql 'SELECT * FROM user'<br />in the same array format like in video? :)))Hey Szymon,
It seems you can't anymore :) They output is displayed in a table now instead of a raw dump as it was before.
Cheers!
For some reason, the "doctrine:fixtures:load" command fails with my PostgresSQL container. I get the error
Question: Is there a way I can tell Doctrine to use
"user"instead ofuserfor that Entity?Or do I need to rename the Entity to something else?
I've tried to apply the quotes via an annotation
#[ORM\Table(name: '"user"')]but that caused a different errorHey Philipp,
Yeah, most probably that's because of that table name,
useris a reserved word in PostgreSql. You need to rename that table to something, likeapp_user.Another trick, you might try to use ticks around the table name, i.e. use `, instead of ":
It might also work, though I've never tried it in PostgreSql, though in MySQL it worked. But safer would be not use reserved words at all, better use a unique name :)
Cheers!
Thanks for the clarification, Victor!
As you suggested, I could solve the issue by renaming the DB table via an annotation + recreating the DB schema
Hey Philipp,
Awesome, thanks for confirming it works for you!
Cheers!
hey ! I have a error
***********
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual
that corresponds to your MariaDB server version for the right syntax to use near 'INDEX idx_9474526c1e27f6bf
TO IDX_DADD4A251E27F6BF' at line 1
********
Column Already exist 'status'
Hey Anass,
It looks like you already have that "status" column. Please, try to validate your DB schema with:
$ symfony console doctrine:schema:validate
If it's not OK - try to apply the required changes, to know what queries you need to execute - see:
$ symfony console doctrine:schema:update --dump-sql
Of if you're working locally and don't worry about losing your data in the DB - instead you can run:
$ symfony console doctrine:schema:update --force
Cheers!
In case anyone else runs into an error trying to run the simple query at the end try using double quotes around the SQL statement instead of single quotes.
Hey Aaron,
Thanks for this tip! Are you talking about "symfony console doctrine:query:sql 'SELECT * FROM user'" command? It somehow does not work for you with single quotes around the SQL query? I wonder what OS do you use and what terminal?
Cheers!
Yes that's the command I'm talking about. When running it on the DOS console on Windows 10 using single quotes it throws an error but with double quotes it does not.
Ha! Windows likes to complicate things. Thanks for sharing your problem + solution with others
"Houston: no signs of life"
Start the conversation!