Download the PHP package luilliarcec/laravel-username-generator without Composer

On this page you can find all versions of the php package luilliarcec/laravel-username-generator. 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 laravel-username-generator

Laravel Username Generator

run-tests Latest Version on Packagist Quality Score Total Downloads GitHub license

Buy Me A Coffee

Laravel Username Generator is a package that allows the versatile generation of user names, has a simple integration with Laravel.

You can generate from the name of the user, taking into account that you do not use more than two names and two surnames in total. It can also be generated from the user's email.

Installation

You can install the package via composer:

We have improved many things so we have decided to launch a new version 2.0.

Please follow this guide if you are going to update to the new version.

Now in AppServiceProvider, add the basic or default configuration to use.:

Note that now you are free to configure as you like from the Facade. You also have the possibility to tell the package, to check with deletions in the model provided.

Upgrade

Upgrading to the new version is as easy as:

Usage

Once configured, you can use the Facade Luilliarcec\LaravelUsernameGenerator\Facades\Username in the following way:

If you want to change the type of case I can do it online, for example:

This will implicitly take the settings from your AppServiceProvider and replace it with the one you provide inline.

New Features

One of the features that I liked to add the most is the possibility that you can create your own driver.

Support for customs drivers

You can create a class that implement the interface Luilliarcec\LaravelUsernameGenerator\Contracts\UsernameDriverContract and inside that class you can write all the logic to generate your username, remember to implement the make method that will be responsible for returning the username, for example:

Usage

Support for multiple models

That's right, you now have the ability to generate usernames for different models. Just pass the space name of your model to the setModel function and you can even s et the column to use to check for existing usernames, for example:

Support for softdelete

And last but not least, if you want your generator to verify usernames with deleted users, now you can with the withTrashed function.

But if you don't use softDelete or don't want to check with deleted users, use the withoutTrashed method. (By default this method is already applied)

¡Important!

Remember that like previous versions it is very important that you provide an Eloquent Model together with the column that stores the username. This is so that the package provides you with an alternate username if it is already in use.

Skipping this step will cause an exception UsernameGeneratorException or that the genarator does not work properly

Examples

Assume you have a user with the username larcec

When using the package to generate the username, it will search thanks to Eloquent, in the database and will buy if that username already exists, if it exists, a pefix will be added to the username.

The result would be as follows.

Laravel Username Generator uses a convention for the creation of user names, takes the first letter of the first name, takes the first last name, and finally the first letter of the second last name

However, Laravel Username Generator is so versatile that it can receive only 1 name, 1 name and 2 surnames, and can even use the auxiliary surname parameter to pass the two surnames separately, in the following ways.

Keep these examples in mind, since passing a value of more or more than two names or two surnames without following the convention may cause an exception

Finally you can use the email driver, which will receive an email as the first and only parameter and take the user's email and use it as a username.

Testing

or

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-username-generator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
laravel/framework Version ^10.0
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 luilliarcec/laravel-username-generator contains the following files

Loading the files please wait ....