Chapters
41 Chapters
|
4:45:40
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.1.3
Subscribe to download the code!Compatible PHP versions: ^7.1.3
-
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!
14.
Registration Form
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!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/annotations": "^1.0", // 1.10.2
"doctrine/doctrine-bundle": "^1.6.10", // 1.10.2
"doctrine/doctrine-migrations-bundle": "^1.3|^2.0", // v2.0.0
"doctrine/orm": "^2.5.11", // v2.7.2
"knplabs/knp-markdown-bundle": "^1.7", // 1.7.0
"knplabs/knp-paginator-bundle": "^2.7", // v2.8.0
"knplabs/knp-time-bundle": "^1.8", // 1.8.0
"nexylan/slack-bundle": "^2.0,<2.2.0", // v2.0.0
"php-http/guzzle6-adapter": "^1.1", // v1.1.1
"phpdocumentor/reflection-docblock": "^3.0|^4.0", // 4.3.0
"sensio/framework-extra-bundle": "^5.1", // v5.2.1
"stof/doctrine-extensions-bundle": "^1.3", // v1.3.0
"symfony/asset": "^4.0", // v4.1.6
"symfony/cache": "^3.3|^4.0", // v4.1.6
"symfony/console": "^4.0", // v4.1.6
"symfony/flex": "^1.0", // v1.21.6
"symfony/form": "^4.0", // v4.1.6
"symfony/framework-bundle": "^4.0", // v4.1.6
"symfony/property-access": "^3.3|^4.0", // v4.1.6
"symfony/property-info": "^3.3|^4.0", // v4.1.6
"symfony/security-bundle": "^4.0", // v4.1.6
"symfony/serializer": "^3.3|^4.0", // v4.1.6
"symfony/twig-bundle": "^4.0", // v4.1.6
"symfony/validator": "^4.0", // v4.1.6
"symfony/web-server-bundle": "^4.0", // v4.1.6
"symfony/yaml": "^4.0", // v4.1.6
"twig/extensions": "^1.5" // v1.5.2
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.0", // 3.0.2
"easycorp/easy-log-handler": "^1.0.2", // v1.0.7
"fzaninotto/faker": "^1.7", // v1.8.0
"symfony/debug-bundle": "^3.3|^4.0", // v4.1.6
"symfony/dotenv": "^4.0", // v4.1.6
"symfony/maker-bundle": "^1.0", // v1.8.0
"symfony/monolog-bundle": "^3.0", // v3.3.0
"symfony/phpunit-bridge": "^3.3|^4.0", // v4.1.6
"symfony/stopwatch": "^3.3|^4.0", // v4.1.6
"symfony/var-dumper": "^3.3|^4.0", // v4.1.6
"symfony/web-profiler-bundle": "^3.3|^4.0" // v4.1.6
}
}
23 Comments
When i'm updating the user enitity, when logged in (for example changhing user information)
I keep getting logged out and the changes won't persist.
How does this work? What do I have to do to edit the currenty logged in User without triggering the logout.
Hey mikesmit1992
That's a bit strange. Do you get logout only when modifying the logged in user? or does it happen when modifying any other user? What steps are you doing to modify the user?
I'm updating the logged in user. I'm rebuilding a project I made in core PHP as a try-out. From the ground up using the videos.
Controller:
FormInterface:
Twig:
Hey mikesmit1992
Could you please answer additional questions? What Symfony version and Which security setup are you using here? Your issue looks like Security logout due to some sensitive User information changes and it detects that your new user object not the same as it was logged in.
Cheers!
@Assert Error messages do not show
im using:
{{ form_row(sform.birthday) }}
/**
* @ORM\Column(type="date",nullable=false)
* @Assert\NotBlank(message="please provide your birthday")
*/
private $Birthday;
but validations shows in the profiler but not as message in the form.
what is weird is that my own validation comes through though
the difference i find in the profiler between both validations
-propertyPath: "children[birthday].data"
-propertyPath: "data.Birthday"
can you tell me what is going on?
Hey mikesmit1992!
Interesting! I have a feeling it's the capitalization on the "Birthday" property in your class vs the "birthday" on your form. This is probably causing the validation errors on the Birthday property to "occur", but then not be rendered on the "birthday" form field (but you should see them on the top of your form, as long as you have
{{ form_errors(sform) }}to render "global" errors).Let me know if that's it - if not, we can dig deeper ;).
Cheers!
I dont have the registration files. In which tutorial did you make the security part? Can you make link it so I can continue from there? Thanks :)
Hey @Farry7
Of course, here it is: https://symfonycasts.com/sc... Also you can find all Symfony4 tutorials by the order here https://symfonycasts.com/tr...
Cheers!
When registering a user via the register form I kept being redirected to the page previously saved in the "target path", which was saved when I tried to access an admin page. I found a workaround by clearing the target path before the redirection on success of LoginFormAutheticaticator class:
`
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey): ?Response
`
Hey Joao P.
That's a default thing that Symfony does. When you try to access a page which you are not authorized, you will be redirected to the login form and after login in Symfony will get you back to the initial page that you tried to access
Cheers!
Hello guys! I advanced with registration in Symfony 4 and i make the registration form but i want to send a confirmation email wth a link. What can i do? I am using SwiftMailer?
Hey codercoder123123!
It's funny you ask about that - we're working on a bundle to help with this right now - https://github.com/SymfonyCasts/verify-email-bundle - unfortunately it's not ready yet!
The easiest way to accomplish this feature is this:
A) Add a
isEmailConfirmedproperty to your User entity and default it to falseB) Add another field called
emailVerificationTokento your User entity and set it to some random string - you can use this code - https://github.com/FriendsOfSymfony/FOSUserBundle/blob/cf7fe27b2f4e1f298ee6eadf537267f8c9f9b85c/Util/TokenGenerator.php - you could do that in the constructor of your User entity, or set it in the controller right after a successful registration.C) Create a route + controller - something like
/email/verify/{token}. In that method, you would look at the currently-authenticated user and, if their emailVerificationToken matches the{token}in the URL, you will call$user->setIsEmailConfirmed(true)and save.D) Finally, after registration, use SwiftMailer (in your case) to send an email that includes a link to the route you generated in (C).
It's not overly complicated - it just takes a bit of work. Let me know if you have any questions. The bundle we're working on will not require a
emailVerificationTokenproperty on your user entity, but if you're building this by hand, I'd recommend leveraging a property like that... as it makes life simpler.Cheers!
Hello! Sorry can we communicate i have a version for this but doesnt work yet. Thank you for everything!
Hey codercoder123123
Can you tell us what problem did you get so I can help you out?
Cheers!
Hello! Why this $url = $this->router->generate('user_activate', array('token' => $user->getToken()), self::ABSOLUTE_URL); generate me an error "Call to a member function generate() on null". Thank you!
Hey codercoder123123
Seems like you forgot to initialize your
routerproperty on its constructorCheers!
Can I send you the code here? I did it, but it isn't here I don't know why.
hello
wen i try to create migration (php bin/console make:migration) for updating user firstname property I got an error:
Attempted to load class "AbstractMigration" from namespace "Doctrine\DBAL\Migrations".
Did you forget a "use" statement for "Doctrine\Migrations\AbstractMigration"?
can you help me with this?
Hey Amin A.
I believe you haven't installed the Doctrine migrations bundle. Once you install it you should not have this error anymore (unless I'm missing something :p)
i'm sorry I am new with symfony but I’m sure that
Doctrine migrations bundle is installed and everything was good until 14 - Registration Form.
The whole message is:
php ./bin/console make:migration
Fatal error: Class 'Doctrine\DBAL\Migrations\AbstractMigration' not found in D:\wamp64\www\the_spacebar\src\Migrations\Version20180413174059.php on line 12
15:22:39 CRITICAL [php] Fatal Error: Class 'Doctrine\DBAL\Migrations\AbstractMigration' not found ["exception" => Symfony\Component\Debug\Exception\FatalErrorException { …}]
In Version20180413174059.php line 12:
Attempted to load class "AbstractMigration" from namespace "Doctrine\DBAL\Migrations".
Did you forget a "use" statement for "Doctrine\Migrations\AbstractMigration"?
when I search for (AbstractMigration.php) I funded in:
doctrine\migrations\lib\Doctrine\Migrations
thanks
Ohh, so the autogenerated namespace was wrong, or what was the problem?
Did you fix it already?
yes, I think autogenerated namespace is wrong, in a (start) folder from Symfony Security tutorials AbstractMigration.php live in two places: ..\vendor\doctrine\migrations\lib\Doctrine\DBAL\Migrations\AbstractMigration.php ..\vendor\doctrine\migrations\lib\Doctrine\Migrations\AbstractMigration.php
but the start folder from Form tutorials is only in
..\vendor\doctrine\migrations\lib\Doctrine\Migrations\AbstractMigration.php I try to reinstall and update bundles and
this did not fix the problem, DBAL folder is not exist in the new tutorial code Form Tutorials: ..\vendor\doctrine\migrations\lib\Doctrine\ folder
Hey Amin A.
This problem is related to a release of Doctrine migration package, we're investigating the issue but at least you can read a couple of solutions that Ryan provides here: https://symfonycasts.com/sc...
Cheers!
"Houston: no signs of life"
Start the conversation!