Download the PHP package c975l/user-bundle without Composer

On this page you can find all versions of the php package c975l/user-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package user-bundle

UserBundle

Directly inspired from FOSUserBundle, and migration of c975L/UserFilesBundle, UserBundle does the following:

UserBundle dedicated web page.

UserBundle API documentation.

Bundle installation

Step 1: Download the Bundle

v3.x works with Symfony 4.x. Use v2.x for Symfony 3.x Use Composer to install the library

Step 2: Configure the Bundle

Check dependencies for their configuration:

And finally in /config/packages/security.yml

Step 3: Create MySql table

Use /Resources/sql/user.sql to create the tables user and user_archives. The DROP TABLE are commented to avoid dropping by mistake. It will also create a stored procedure sp_UserArchive().

Step 4: Enable the Routes

Then, enable the routes by adding them to the /config/routes.yaml file of your project:

Step 5: install assets to web folder

Install assets by running

It will create a link from folder Resources/public/ in your web folder.

Overriding Templates

It is strongly recommended to use the Override Templates from Third-Party Bundles feature to integrate fully with your site.

For this, simply, create the following structure /templates/bundles/c975LUserBundle/ in your app and then duplicate the file layout.html.twig in it, to override the existing Bundle files, then apply your needed changes.

You can also override:

You can add a navbar menu via {% include('@c975LUser/fragments/navbarMenu.html.twig') %}. You can override it, if needed, or simply override /templates/bundles/c975LUserBundle/fragments/navbarMenuActions.html.twig to add actions above it.

Routes

The Routes availables are:

Entities

You must choose an entity linked to your needs and specify it in the /config/packages/security.yml. Available entities are the following:

To help you choose, the fields are the following:

LIGHT

DEFAULT

ADDRESS

BUSINESS

SOCIAL

You can also create your own Class by extending one of the Abstract classes with the following code:

Extending Forms

You can extend UserSignupType and UserProfileType. To extend them, to include new properties or features, simply use the following code:

Then you have to add it as a service in your app/config/services.yml:

And finally, you have to set it in your app/config/config.yml

Events

Multiples events are fired to help you fit your needs, they are all defined in Event\UserEvent.php. For example if you need to perform taks before deleting a user, you can create a Listener like this:

Service

You can inject c975L\UserBundle\Service\UserServiceInterface to access its methods. For example you can retrieve a user with its id, email, socialId, ...

Sign in/Sign out link

If you want to insert a link to sign in/sign out, i.e. in the footer, you can do it via this code:

User Div data for javascript use

If you want to insert a div containing the user's data, to be used by javascript, you can do it via the Twig extension:

Then you can access it via

Have a look at it to see the properties covered.

Custom redirect after sign in

If you want to redirect to a specific page you can use Request Parameters with the following code:

User's avatar

You can display the avatar linked to user's account (if enabled in config.yml) by calling the Twig extension where you want to place it:

Twig extension

You can use Twig extensions to format VAT and Siret numbers.

Using HwiOauth (Social network sign in)

On the sign in form you can add links to sign in/sign up with social networks via HWIOAuthBundle. If you want to this feature, simply add in your /config/config_bundles.yaml or using c975L\ConfigBundle and clear the cache, the following:

And in your /config/services.yaml, the following:

c975L/UserBundle doesn't implement the connection with social networks but provides a bridge with HWIOAuthBundle. To display buttons on the sign in page and to store users in the DB, you have to configure HWIOAuthBundle by your own. This will mainly consist in setting differents informations in config files. As an example, they are listed below, for Facebook, but other networks will work in the same way:

You will have to declare the account_connector c975L\UserBundle\Security\OAuthUserProvider

You will have to declare the oauth_user_provider c975L\UserBundle\Security\OAuthUserProvider

Social networks images

c975L/UserBundle provides images for some of the social networks, they were linked in your web folder when you have installed the assets (see above). If the network you want to use has not an image yet, you can use the file `Resources/SocialNetwork/signin.svg`` to build one and make a PR to add it to the bundle :-).

You can also override Resources/views/fragments/socialNetworkImage.html.twig with your own pictures set or to change the styles used.

As a "Bonus" if a user has signed up with its email address and then use a social network to signin, it will get its existing user account IF emails addresses are the same, otherwise, it will create another account.

Signing up with another social network, after having already signed up with a different one, will replace the current one by the new one.

Migration from FOSUserBundle

If you want to migrate from FOSUserBundle, you have to do the following:

Remove from composer

Migrate your database table, by using Resources\sql\MigrateFosUser.sql. It will create a user_migrate table, will modify all the needed fields, will add missing ones, then, when you are ready, you can rename your FOSUSerBundle table to user_fosuserbundle (or whatever you want) and rename the user_migrate one to user. Fields username and groups are kept but not used, so you can delete them if you don't use them.

API Documentation

You can also use the API provided in c975LUserBundle with the following:

You have to use https://github.com/lcobucci/jwt (openssl extension is required).

Then create your RSA keys:

Add those paths to /config/config_bundles.yaml or using c975L\ConfigBundle :

Define the JSON end point in your security.yaml:

Then you can use the different Routes :

Except for user_api_create and user_api_authenticate you need to send the JWT (obtained via user_api_authenticate) in the header Authorization: Bearer <token> (recommended) or in the header X-AUTH-TOKEN: <token> for all the API Routes requests.

/user/api/create

methods={"HEAD", "POST"}. To create the user, call the Route, in a POST request, user_api_create with the form-data fields needed by the User entity chosen (see above). Fields email and plainPassword are mandatory any other will be added to the Entity if the Method exists. You also need to add a field apiKey which consists of sha1($email . apiPassword), apiPassword is defined in the user_config Route. It is also recommended to define CORS access.

/user/api/authenticate

methods={"HEAD", "POST"}. To authenticate, call the Route user_api_authenticate with the JSON body {"username": "<email>", "password": "<password>"} in a POST request, with the header Content-Type: application/json, you will receive a token. You can fix the expiration time of the JWT by adding "expiration": <delay_inseconds> to the json data sent.

/user/api/display/{identifier}

methods={"HEAD", "GET"}, {identifier} -> [0-9a-z]{32}. To display the user, call the Route user_api_display, in a GET request, with the identifier of the user. The user defined in JWT must have sufficients rights, as configured in user_config Route or be the user itself.

/user/api/list[?page=1&size=50]

methods={"HEAD", "GET"}. To list the users, call the Route user_api_list in a GET request. You can use the query parameters page (default 1) to define which page and size (default 50) to define the number of records to display. The user defined in JWT must have sufficients rights, as configured in user_config Route.

/user/api/search/{term}[?page=1&size=50]

methods={"HEAD", "GET"}, {term} -> [0-9a-zA-Z]+. To search within the users, call the Route user_api_search, in a GET request, with the term searched that will be matched as %term% with the email field of the User entity. You can use the query parameters page (default 1) to define which page and size (default 50) to define the number of records to display. The user defined in JWT must have sufficients rights, as configured in user_config Route.

/user/api/modify/{identifier}

methods={"HEAD", "PUT"}, {identifier} -> [0-9a-z]{32}. To modify the user, call the Route user_api_modify in a PUT request, with the identifier of the user and the data fields in the body of the request i.e. {"email": "[email protected]"} needed by the User entity chosen (see above). The user defined in JWT must have sufficients rights, as configured in user_config Route or be the user itself.

/user/api/delete/{identifier}

methods={"HEAD", "DELETE"}, {identifier} -> [0-9a-z]{32}. To delete the user, call the Route user_api_delete in a DELETE request, with the identifier of the user. the user will be archived if you have defined it in the Config parameters. The user defined in JWT must have sufficients rights, as configured in user_config Route or be the user itself.

/user/api/add-role/{identifier}/{role}

methods={"HEAD", "PUT"}, {identifier} -> [0-9a-z]{32}, {role} -> [a-zA-Z\_]+. To add a Role to the user, call the Route user_api_add_role in a PUT request, with the identifier of the user and the role you want to assign. The user defined in JWT must have sufficients rights, as configured in user_config Route.

/user/api/delete-role/{identifier}/{role}

methods={"HEAD", "PUT"}, {identifier} -> [0-9a-z]{32}, {role} -> [a-zA-Z\_]+. To delete a Role of the user, call the Route user_api_delete_role in a PUT request, with the identifier of the user and the role you want to delete. The user defined in JWT must have sufficients rights, as configured in user_config Route.

/user/api/modify-roles/{identifier}

methods={"HEAD", "PUT"}, {identifier} -> [0-9a-z]{32}. To modify the Roles of the user, call the Route user_api_modify_roles in a PUT request, with the identifier of the user and an array of roles in the body of the request i.e. {"roles": ["ROLE_ADMIN", "ROLE_USER"]}. The user defined in JWT must have sufficients rights, as configured in user_config Route.

/user/api/change-password

methods={"HEAD", "PUT"}. To change the password of a defined user, call the Route user_api_change_password in a PUT request with the data field plainPassword in the body of the request i.e. {"plainPassword": "BrandNewPass*$1"}. Only the user defined in JWT can change its password.

/user/api/reset-password & /user/api/reset-password-confirm

methods={"HEAD", "PUT"}. To reset the password of a defined user, call the Route user_api_reset_password in a PUT request with an array with the field email in the body of the request i.e. {"email": "[email protected]"}, you will receive a token and its validity time (2 hours later). Then, to confirm (and change) the password, you have to call the route user_api_reset_password_confirm with /user/api/reset-password-confirm/{token} with the data field plainPassword in the body of the request i.e. {"plainPassword": "BrandNewPass*$1"}.

/user/api/export

methods={"HEAD", "GET"}. To export user's data, call the Route user_api_export in a GET request. Only the user defined in JWT can access its data. If you wish to add data you can listen to UserEvent::API_USER_EXPORT and update the user or you can export your own foramtted data by using the following in an EventListener:

If this project help you to reduce time to develop, you can sponsor me via the "Sponsor" button at the top :)


All versions of user-bundle with dependencies

PHP Build Version
Package Version
Requires php Version *
c975l/config-bundle Version ^2
c975l/email-bundle Version ^4
c975l/includelibrary-bundle Version ^1
c975l/services-bundle Version ^1
c975l/toolbar-bundle Version ^1
knplabs/knp-paginator-bundle Version *
lcobucci/jwt Version *
odolbeau/phone-number-bundle Version *
symfony/form Version *
symfony/security Version *
symfony/serializer Version *
symfony/translation Version *
symfony/validator Version *
twig/intl-extra Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package c975l/user-bundle contains the following files

Loading the files please wait ....