Skip to content

Add recipe for FOSUserBundle #270

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

Merged
9 commits merged into from
Apr 6, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions friendsofsymfony/user-bundle/2.1/config/packages/fos_user.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fos_user:
db_driver: no_driver # valid values are 'orm', 'mongodb' and 'couchdb'
user_class: App\Entity\User
firewall_name: main
service:
mailer: fos_user.mailer.noop
from_email:
address: "%env(MAILER_SENDER_ADDRESS)%"
sender_name: "%env(MAILER_SENDER_NAME)%"

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
13 changes: 13 additions & 0 deletions friendsofsymfony/user-bundle/2.1/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"bundles": {
"FOS\\UserBundle\\FOSUserBundle": ["all"]
},
"copy-from-recipe": {
"config/": "%CONFIG_DIR%/",
"src/": "%SRC_DIR%/"
},
"env": {
"MAILER_SENDER_ADDRESS": "[email protected]",
"MAILER_SENDER_NAME": "John Doe"
}
}
21 changes: 21 additions & 0 deletions friendsofsymfony/user-bundle/2.1/post-install.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<bg=blue;fg=white> </>
<bg=blue;fg=white> What's next? </>
<bg=blue;fg=white> </>

- If not, install a driver storage and change it in <fg=green>config/packages/fos_user.yaml</>

- Modify your email address config in <fg=green>.env</>

- Uncomment <fg=green>csrf_protection</> and make sure <fg=green>twig engine</> is turned on by adding in <fg=green>config/packages/framework.yaml</>:

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

- Create your User class
https://symfony.com/doc/master/bundles/FOSUserBundle/index.html#step-3-create-your-user-class

- Modify your security configuration in <fg=green>config/packages/security.yaml</>
https://symfony.com/doc/master/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
}
}