Download the PHP package codersvn/usermanagement without Composer
On this page you can find all versions of the php package codersvn/usermanagement. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package usermanagement
User Component for Laravel and Lumen
The User Component package provides a convenient way of managing application's users.
Table of content
- User Component for Laravel and Lumen
- Table of content
- Installation
- Composer
- Service provider
- Laravel
- Lumen
- Config and Migration
- Laravel
- Lumen
- Environment
- Configuration
- URL Namespace
- User Model
- User Transformer
- Laravel
- Lumen
- Social login
- User Model
- User Schema
- User Management
- APIs List
- Routing
- Custom Routing
- Custom Controller
- Additional Configuration
Installation
Composer
To include the package in your project, Please run following command.
Once the package is installed, the next step is dependant on which framework you are using.
Service provider
Laravel
In your config/app.php
add the following Service Providers to the end of the providers
array:
Lumen
In your bootstrap/app.php
add the following Service Providers.
You also need to define route
in bootstrapp/app.php
.
Config and Migration
Laravel
Run the following commands to publish configuration and migration files.
Create tables.
Please delete the Laravel default
users
migration file to avoid conflict when running the migrate command.
Make a change in config/auth.php
.
Lumen
Create config/auth.php
file and add the following contents.
Create the following migration files.
Add these following contents to those corresponding migration files
Create tables.
Environment
In .env
file, we need some configuration.
Generate JWT_SECRET
in .env
file.
Now the package is ready to use.
Configuration
URL Namespace
To avoid duplication with your application's api endpoints, the package has a default namespace for its routes which is user-management
. For example:
You can modify the package url namespace to whatever you want by modifying the USER_MANAGEMENT_NAMESPACE
variable in .env
file.
User Model
You can use your own User
model by modifying config/auth.php
Your User
model must has the following content.
User Transformer
Laravel
You can use your own UserTransformer
class by modifying config/user.php
.
Lumen
Create config/user.php
with the following content.
Now you can modify UserTransformer
class.
Social login
To be able to use social login api provided by the package, you have to add these configuartion to config/services.php
User Model
User Schema
By default, the package provides some very basic fields in users
table. In your application, you may want to have your own fields in users
table to meet your application's requirements. It can be solved thanks to the User Meta system within the package which holds any additional fields datas you include.
The package provides a way to describe your additional fields throught schema()
method. In schema()
, you'll need to define your field name
, field type
and field validation rule
.
All you need to do is declaring schema()
method in your User
model.
User Management
In your application, you may want to determine if the user is granted to access user resources. The package provides UserManagementTrait
which contains the logic for granting access. The UserMangementTrait
contains 5 methods: ableToShow()
, ableToCreate()
, ableToUpdate()
, ableToUpdateProfile()
, ableToDelete()
. These methods will execute the checking logic and then return boolean value.
To overwrite the default logic with your own, all you need to do is declaring these methods within your User
model.
Take a look at
VCComponent\Laravel\User\Traits\UserManagementTrait
for more details of these methods.
APIs List
Here is the list of APIs provided by the package.
Verb | URI | Action |
---|---|---|
POST | /api/{namespace}/register |
register |
POST | /api/{namespace}/login |
login |
POST | /api/{namespace}/login/social |
social login |
GET | /api/{namespace}/me |
get profile |
PUT | /api/{namespace}/me/avatar |
update avatar |
PUT | /api/{namespace}/me/password |
update password |
POST | /api/{namespace}/password/email |
forgot password |
PUT | /api/{namespace}/password/reset |
reset password |
------ | ------ | ------ |
GET | /api/{namespace}/admin/users |
index |
GET | /api/{namespace}/admin/users/all |
list all |
POST | /api/{namespace}/admin/users |
store |
GET | /api/{namespace}/admin/users/{id} |
show |
PUT | /api/{namespace}/admin/users/{id} |
update |
DELETE | /api/{namespace}/admin/users/{id} |
destroy |
PUT | /api/{namespace}/admin/users/status/bulk |
bulk update status |
PUT | /api/{namespace}/admin/users/status/{id} |
update item status |
------ | ------ | ------ |
GET | /api/{namespace}/users |
index |
GET | /api/{namespace}/users/all |
list all |
GET | /api/{namespace}/users/{id} |
show |
PUT | /api/{namespace}/users/{id} |
update |
PUT | /api/{namespace}/users/{id}/verify-email |
verify email |
GET | /api/{namespace}/users/{id}/is-verified-email |
is verified email |
POST | /api/{namespace}/users/{id}/resend-verify-email |
resend verify email |
Routing
Custom Routing
To use your own routes, you need to remove VCComponent\Laravel\User\Providers\UserComponentRouteProvider
within config/app.php
.
Now you can manually create and use your own routes.
Custom Controller
You are free to use your own UserController
to customize the API functionality.
To make sure that your changes won't crash the other functionality, your UserController
need to extend VCComponent\Laravel\User\Http\Controller\ApiController
and use UserAdminMethods
trait for admin controller, UserFrontendMethods
trait for frontend controller.
Additional Configuration
The package contains 3 other packages which are dingo/api
, tymon/jwt-auth
, prettus/l5-repository
.
Other configurations of these packages, please follow their documentation.
All versions of usermanagement with dependencies
prettus/l5-repository Version ^2.6
tymon/jwt-auth Version ^1.0@dev
laravel/socialite Version ^3.1