Chapters
35 Chapters
|
3:22:53
|
This course is archived!
This tutorial uses an older version of Symfony of the stripe-php SDK. The majority of the concepts are still valid, though there *are* differences. We've done our best to add notes & comments that describe these changes.
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: >=5.5.9, <7.4
Subscribe to download the code!Compatible PHP versions: >=5.5.9, <7.4
-
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.
Stripe Events & Webhooks
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.
This tutorial uses an older version of Symfony of the stripe-php SDK. The majority of the concepts are still valid, though there *are* differences. We've done our best to add notes & comments that describe these changes.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=5.5.9, <7.4",
"symfony/symfony": "3.1.*", // v3.1.10
"doctrine/orm": "^2.5", // v2.7.2
"doctrine/doctrine-bundle": "^1.6", // 1.6.8
"doctrine/doctrine-cache-bundle": "^1.2", // 1.3.0
"symfony/swiftmailer-bundle": "^2.3", // v2.6.2
"symfony/monolog-bundle": "^2.8", // v2.12.1
"symfony/polyfill-apcu": "^1.0", // v1.3.0
"sensio/distribution-bundle": "^5.0", // v5.0.22
"sensio/framework-extra-bundle": "^3.0.2", // v3.0.26
"incenteev/composer-parameter-handler": "^2.0", // v2.1.2
"friendsofsymfony/user-bundle": "~2.0.1", // v2.0.1
"stof/doctrine-extensions-bundle": "^1.2", // v1.2.2
"stripe/stripe-php": "^3.15", // v3.23.0
"doctrine/doctrine-migrations-bundle": "^1.1", // v1.2.1
"phpunit/phpunit": "^5.5", // 5.7.20
"composer/package-versions-deprecated": "^1.11" // 1.11.99
},
"require-dev": {
"sensio/generator-bundle": "^3.0", // v3.1.4
"symfony/phpunit-bridge": "^3.0", // v3.3.0
"hautelook/alice-bundle": "^1.3", // v1.4.1
"doctrine/data-fixtures": "^1.2" // v1.2.2
}
}
8 Comments
Hey,
One last thing: i want to let the users register and i got the awful basic template from FOSuserbundle, but how can i change the style to bootstrap design? like you did for the login. Is there an easy way to overwrite te basic style, cause i searched the web and there was no clear information about that.
what do i have to do to chage the styling ?
when i copy the code from login.html.twig and paste it into the Registration/register_content.html.twig it actually shows me the bootstrap style and i can change the form groups to username, email, password and repeat password, but i have no _csrf_token and no errors variable, it says there is no variable like that.
I know that in the RegistrationController is the logic behind the form and i also know where to pass the eroor and csrf token: In the last array from the render return i have to setup the variable, but how can i catch an error there? or the csrf token? or am i going into the wrong direction? is there an easier way of doing that?
Thanks a lot :)
Yo Blueblazer172!
Ok, so there are basically 2 things you need to know about styling the FOSUserBundle templates. And btw, the templates are horribly styled by design - the idea is that you will definitely need to override them... so they're made plain.
1) Most of what you see on the registration page are the form fields. How the form fields are rendered is based on your form theme. Make sure you've configured the bootstrap form theme: http://knpuniversity.com/screencast/symfony-forms/render-form-bootstrap
2) You will also need to override the layout file used by the bundle. The docs are here: https://symfony.com/doc/master/bundles/FOSUserBundle/overriding_templates.html#example-overriding-the-default-layout-html-twig. But, the docs are incomplete! The directions for how to override this are correct, but the example layout.html.twig template they have is wrong. It should be:
Basically, FOSUserBundle doesn't even know that your bundle has a base.html.twig base layout file. So, instead, all of its templates extend this layout.html.twig... which has almost not styling on it. LAME! To make FOSUserBundle's templates use base.html.twig, you basically override their layout file, and make sure that the contents of the fos_user_content block (this is the block where all of the FOSUserBundle's templates put their content) is rendered in the body block area (which is usually the name of the block in base.html.twig where our content goes). The tl;dr of this step is that the registration page will now start using your base layout... which is important because without this, your bootstrap.css file is never included.
You may also want to override the individual templates. For example, to override the registration template, you can override this template: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/views/Registration/register_content.html.twig
If you have more questions about this - let me know! I'm giving you the 80% explanation - not sure what things you do or don't have experience in (e.g. forms, etc) :)
Cheers!
I've successfully figured it out during today, but thanks anyways :)
but there is one little thing that does not work...
i loop through every error for each field. that could be done in one for loop. but i don't know. so here is the register.html.twig file: http://pastebin.com/6H5w51qn
what do i have to change?
Hey Blueblazer172
You can simplify all of this work, if you just render the whole form like this
or you can render field by field using the form_row(form.field) function
You might find this tutorial very helpful:
https://knpuniversity.com/screencast/symfony-forms
Have a nice day!
thanks :)
but how can i simplify this code:
Hey Blueblazer172
If you only want to render field errors, you can do something like this
{{ form_errors(form.field) }}
for every field you want to render
Cheers!
thanks you are amazing :)) finally it is working as i want to have it :)
best english :)
I'm glad to hear you could achieved it :)
If you have more questions, don't hesitate to contact us
"Houston: no signs of life"
Start the conversation!