|
3
|
1 |
FOSUserBundle Command Line Tools |
|
|
2 |
================================ |
|
|
3 |
|
|
|
4 |
The FOSUserBundle provides a number of command line utilities to help manage your |
|
|
5 |
application's users. Commands are available for the following tasks: |
|
|
6 |
|
|
|
7 |
1. Creating a User |
|
|
8 |
2. Activating a User |
|
|
9 |
3. Deactivating a User |
|
|
10 |
4. Promoting a User |
|
|
11 |
5. Demoting a User |
|
|
12 |
6. Change a User's Password |
|
|
13 |
|
|
|
14 |
**Note:** |
|
|
15 |
|
|
|
16 |
``` |
|
|
17 |
You must have correctly installed and configured the FOSUserBundle before using |
|
|
18 |
these commands. |
|
|
19 |
``` |
|
|
20 |
|
|
|
21 |
### Create a User |
|
|
22 |
|
|
|
23 |
You can use the `fos:user:create` command to create a new user for your application. |
|
|
24 |
The command takes three arguments, the `username`, `email`, and `password` for |
|
|
25 |
the user you are creating. |
|
|
26 |
|
|
|
27 |
For example if you wanted to create a user with username `testuser`, with email |
|
|
28 |
`test@example.com` and password `p@ssword`, you would run the command as follows. |
|
|
29 |
|
|
|
30 |
``` bash |
|
|
31 |
$ php app/console fos:user:create testuser test@example.com p@ssword |
|
|
32 |
``` |
|
|
33 |
|
|
|
34 |
If any of the required arguments are not passed to the command, an interactive prompt |
|
|
35 |
will ask you to enter them. For example, if you ran the command as follows, then |
|
|
36 |
you would be prompted to enter the `email` and `password` for the user |
|
|
37 |
you want to create. |
|
|
38 |
|
|
|
39 |
``` bash |
|
|
40 |
$ php app/console fos:user:create testuser |
|
|
41 |
``` |
|
|
42 |
|
|
|
43 |
There are two options that you can pass to the command as well. They are |
|
|
44 |
`--super-admin` and `--inactive`. |
|
|
45 |
|
|
|
46 |
Specifying the `--super-admin` option will flag the user as a super admin when |
|
|
47 |
the user is created. A super admin has access to any part of your application. |
|
|
48 |
An example is provided below: |
|
|
49 |
|
|
|
50 |
``` bash |
|
|
51 |
$ php app/console fos:user:create adminuser --super-admin |
|
|
52 |
``` |
|
|
53 |
|
|
|
54 |
If you specify the `--inactive` option, then the user that you create will no be |
|
|
55 |
able to login until he is activated. |
|
|
56 |
|
|
|
57 |
``` bash |
|
|
58 |
$ php app/console fos:user:create testuser --inactive |
|
|
59 |
``` |
|
|
60 |
|
|
|
61 |
### Activate a User |
|
|
62 |
|
|
|
63 |
The `fos:user:activate` command activates an inactive user. The only argument |
|
|
64 |
that the command requires is the `username` of the user who should be activated. |
|
|
65 |
If no `username` is specified then an interactive prompt will ask you |
|
|
66 |
to enter one. An example of using this command is listed below. |
|
|
67 |
|
|
|
68 |
``` bash |
|
|
69 |
$ php app/console fos:user:activate testuser |
|
|
70 |
``` |
|
|
71 |
|
|
|
72 |
### Deactivate a User |
|
|
73 |
|
|
|
74 |
The `fos:user:deactivate` command deactivates a user. Just like the activate |
|
|
75 |
command, the only required argument is the `username` of the user who should be |
|
|
76 |
activated. If no `username` is specified then an interactive prompt will ask you |
|
|
77 |
to enter one. Below is an example of using this command. |
|
|
78 |
|
|
|
79 |
``` bash |
|
|
80 |
$ php app/console fos:user:deactivate testuser |
|
|
81 |
``` |
|
|
82 |
|
|
|
83 |
### Promote a User |
|
|
84 |
|
|
|
85 |
The `fos:user:promote` command enables you to add a role to a user or make the |
|
|
86 |
user a super administrator. |
|
|
87 |
|
|
|
88 |
If you would like to add a role to a user you simply pass the `username` of the |
|
|
89 |
user as the first argument to the command and the `role` to add to the user as |
|
|
90 |
the second. |
|
|
91 |
|
|
|
92 |
``` bash |
|
|
93 |
$ php app/console fos:user:promote testuser ROLE_ADMIN |
|
|
94 |
``` |
|
|
95 |
|
|
|
96 |
You can promote a user to a super administrator by passing the `--super` option |
|
|
97 |
after specifying the `username`. |
|
|
98 |
|
|
|
99 |
``` bash |
|
|
100 |
$ php app/console fos:user:promote testuser --super |
|
|
101 |
``` |
|
|
102 |
|
|
|
103 |
If any of the arguments to the command are not specified then an interactive |
|
|
104 |
prompt will ask you to enter them. |
|
|
105 |
|
|
|
106 |
**Note:** You may not specify the `role` argument and the `--super` option simultaneously. |
|
|
107 |
|
|
|
108 |
### Demote a User |
|
|
109 |
|
|
|
110 |
The `fos:user:demote` command is similar to the promote command except that |
|
|
111 |
instead of adding a role to the user it removes it. You can also revoke a user's |
|
|
112 |
super administrator status with this command. |
|
|
113 |
|
|
|
114 |
If you would like to remove a role from a user you simply pass the `username` of |
|
|
115 |
the user as the first argument to the command and the `role` to remove as the |
|
|
116 |
second. |
|
|
117 |
|
|
|
118 |
``` bash |
|
|
119 |
$ php app/console fos:user:demote testuser ROLE_ADMIN |
|
|
120 |
``` |
|
|
121 |
|
|
|
122 |
To revoke the super administrator status of a user, simply pass the `username` as |
|
|
123 |
an argument to the command as well as the `--super` option. |
|
|
124 |
|
|
|
125 |
``` bash |
|
|
126 |
$ php app/console fos:user:demote testuser --super |
|
|
127 |
``` |
|
|
128 |
|
|
|
129 |
If any of the arguments to the command are not specified then an interactive |
|
|
130 |
prompt will ask you to enter them. |
|
|
131 |
|
|
|
132 |
**Note:** You may not specify the `role` argument and the `--super` option simultaneously. |
|
|
133 |
|
|
|
134 |
### Change a User's Password |
|
|
135 |
|
|
|
136 |
The `fos:user:change-password` command provides an easy way to change a user's |
|
|
137 |
password. The command takes two arguments, the `username` of the user whose |
|
|
138 |
password you would like to change and the new `password`. |
|
|
139 |
|
|
|
140 |
``` bash |
|
|
141 |
$ php app/console fos:user:change-password testuser newp@ssword |
|
|
142 |
``` |
|
|
143 |
|
|
|
144 |
If you do not specify the `password` argument then an interactive prompt will |
|
|
145 |
ask you to enter one. |