Laravel Artisan Utilities - How to use

Posted by Andy Huggins on June 24, 2016

 

The Utilities package can be found here: ahuggins/utilities

Installation

It's pretty straight forward as most Composer packages...simply run the following command in the shell:

composer require ahuggins/utilities

Composer should bring in the latest version, which if I hear a good idea I will gladly add it to the package.

Then you need to add the following to the config/app.php file in the providers array:

AHuggins\Utilities\Providers\UtilityServiceProvider::class,

Once that is added, you should be able to run `php artisan` and see the `utils` section in the Command list.

As of the date of this post, there are two commands: CreateUser and UserPassword.

CreateUser

To run the CreateUser command, simple run this in the shell: `php artisan utils:create-user` and answer the questions.

UserPassword

To run the UserPassword command, use the following: `php artisan utils:pw` if you know the id of the user you want to edit then do this: `php artisan utils:pw 42`

If you do not provide an id, then a table of users will be shown. This is intended for dev use, which normally will have only a few users in the db. If you have tons of users, it might be cumbersome to edit a user (or additional work may be needed for this package). Once the user is determined, it will ask you for a password. Type it in and hit enter.

When typing the password, the input is hidden. This is to help prevent anyone looking over your shoulder. Just know that there is no visual feedback on the password fields

If you want to see this in action, here is a screencast of the package being used:

 

Contact me @andy_huggins on Twitter