Download the PHP package yooslim/legit-artisan-commands without Composer

On this page you can find all versions of the php package yooslim/legit-artisan-commands. 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 legit-artisan-commands

Introduction

This package allows you as a developer to restrict who can and cannot run artisan commands, especially in a production environment. For example, a user (admin) should be allowed to run commands only if he has the right role/permission.

How it works ?

An artisan user will be provided with a token in order to use it as an option when running commands. This token has a configurable size and lifetime. The user can use this token as much as he wants until it expires or is revoked.

In order to get this token, an artisan user must first perform an authentication within the console, if the authentication is successful, the user will be prompted with the token, otherwise, a warning message will be displayed.

The logic of authentication is customizable, the developer can put in place his own validation rules. For exemple, one would want to authorize a user only if he has an "admin" role, an other one would check if he has the right permissions, another one would fetch an active directory or external authentication service, etc.

How to implement it !

A few steps to put this in place.

Install the package

composer require yooslim/legit-artisan-commands

Publish the vendor configuration file

php artisan vendor:publish --provider="YOoSlim\LegitArtisanCommands\Providers\LegitCommandsServiceProvider"

Edit configuration file

Run migrations

php artisan migrate

Add the ArtisanUserInterface to the user model

Customize your authentication logic in AppServiceProvider.php

Finally, edit your artisan command

There are two main things to edit in your command :

  1. Add the LegitArtisanCommandSignature trait, it will edit your command signature by appending the --token option part.
  2. Wrap your original command inside the isAuthorized callback function.

How to use it !

  1. First, request a token by providing your credentials.

php artisan console:authentication --username="[email protected]"

This will prompt a random token.

  1. Then, whenever you use a protected artisan command, include the --token option.

php artisan MyCommand:MyAction --token="*"

Enjoy :D

Please, let me know if something is ambiguous, incomprehensible or wrong. I would be glad to clarify or fix it.


All versions of legit-artisan-commands with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0.2
laravel/framework Version ^9.11
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 yooslim/legit-artisan-commands contains the following files

Loading the files please wait ....