Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recipe for FOSUserBundle #270

Merged
9 commits merged into from
Apr 6, 2019
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fos_user:
db_driver: orm
service:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move service block between user_class and from_email for more readability please?

mailer: fos_user.mailer.noop
firewall_name: main
user_class: App\Entity\User
from_email:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use that :

from_email:
        address: '%env(MAILER_SENDER_ADDRESS)%'
        sender_name: '%env(MAILER_SENDER_NAME)%'

address: "address"
sender_name: "name"
Copy link
Contributor

@covex-nn covex-nn Feb 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tattali FOSUserBundle can be used without templating service. Add this to use twig directly:

fos_user:
    service:
        mailer: fos_user.mailer.twig_swift

It can be used even without mailer service, if a bug will be fixed (PR is not accepted/merged yet). See FriendsOfSymfony/FOSUserBundle#2707 and FriendsOfSymfony/FOSUserBundle#2704

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sorry when I did the search I did not see your recipe. If you want we can use yours that looks more accomplished.

Copy link
Contributor

@covex-nn covex-nn Feb 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no my recipe as there is no v2.1 release yet =) And it is not possible to create recipe right now, because even with new fos_user.service.mailer parameter, FOSUB will require doctrine-bundle for fos_user.db_driver: orm. I've created PR FriendsOfSymfony/FOSUserBundle#2708 ~~~but they ignore me =)~~~

18 changes: 18 additions & 0 deletions friendsofsymfony/user-bundle/2.1/config/routes/fos_user.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
fos_user_security:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you didn't load the routes like that ?

fos_user:
    resource: '@FOSUserBundle/Resources/config/routing/all.xml'

Copy link
Contributor Author

@tattali tattali Aug 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People may not need every routes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, it seems good to me 👍
I can not wait to see this merged

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

me too I hope this PR FriendsOfSymfony/FOSUserBundle#2708 will be merged soon

resource: "@FOSUserBundle/Resources/config/routing/security.xml"

fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile

fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register

fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting

fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
9 changes: 9 additions & 0 deletions friendsofsymfony/user-bundle/2.1/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"bundles": {
"FOS\\UserBundle\\FOSUserBundle": ["all"]
},
"copy-from-recipe": {
"config/": "%CONFIG_DIR%/",
"src/": "%SRC_DIR%/"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the env var

,
"env": {
    "MAILER_SENDER_ADDRESS": "[email protected]",
    "MAILER_SENDER_NAME": "John Doe"
}

}
18 changes: 18 additions & 0 deletions friendsofsymfony/user-bundle/2.1/post-install.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<bg=blue;fg=white> </>
<bg=blue;fg=white> What's next? </>
<bg=blue;fg=white> </>

Warning: make sure the twig engine is turned on in framework.yaml

- Modify your email address config in <fg=green>config/packages/fos_user.yaml</>

- If not, add the following to <fg=green>config/packages/framework.yaml</>:

framework:
# ...
csrf_protection: { enabled: true }
templating:
engines: ['twig']

- Modify your security configuration in <fg=green>config/packages/security.yaml</>
https://symfony.com/doc/2.0/bundles/FOSUserBundle/index.html#step-4-configure-your-application-s-security-yml
26 changes: 26 additions & 0 deletions friendsofsymfony/user-bundle/2.1/src/Entity/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User as BaseUser;

/**
* @ORM\Entity
* @ORM\Table(name="fos_user")
*/
class User extends BaseUser
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you switch order with line above please

Copy link
Contributor Author

@tattali tattali Aug 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entity is maybe going to disappear because it's a doctrine orm entity and not mongo or couchdb

* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;

public function __construct()
{
parent::__construct();
// your own logic
}
}