Download the PHP package masgeek/artisan-toolkit without Composer
On this page you can find all versions of the php package masgeek/artisan-toolkit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package artisan-toolkit
masgeek/artisan-toolkit
A collection of custom and override Artisan commands for Laravel. Enable only what you need via a single published config file.
Installation
Publish the config:
Configuration
The published config/artisan-toolkit.php controls which commands are active and configures package-wide settings:
Setting a command value to false (or removing the entry) disables it and leaves Laravel's built-in in place.
model_scan_paths
Directories (relative to your app's base path) that model:prune-orphaned scans when no --path option is given on the CLI. Adjust this list to match your project's model layout:
Available overrides
schema:dump
The built-in php artisan schema:dump --prune deletes every file under database/migrations/. This override changes --prune to only delete migration files whose name exists in the migrations table — pending (unrun) migrations are kept on disk.
Output when --prune is used:
key:generate
Overrides the native key:generate command to rotate the application key. The old APP_KEY is appended to APP_PREVIOUS_KEYS in .env, a new key is generated, and all configured encrypted model attributes are re-encrypted with the new key.
The command prompts for confirmation before proceeding. Use --force to skip the prompt (e.g. in scripts or CI). Use --new for a fresh application setup (skips rotation, re-encryption, and model checks).
| Option | Description |
|---|---|
--new |
Fresh application setup — generate key without rotation or re-encryption |
--show |
Print the generated key without applying changes |
--force |
Skip confirmation prompts; allow running in production |
--no-env-file |
Skip .env writes; prints the new key and previous keys for manual injection |
--reverse |
Roll back key rotations using previous keys |
--steps=N |
Number of rotations to roll back (default: 1, used with --reverse) |
The command fails early if no models are defined in encrypted_models or none of the configured models are valid. This prevents accidental key rotation without re-encrypting sensitive data.
When --no-env-file is used, the command outputs the APP_KEY and APP_PREVIOUS_KEYS values so they can be injected as environment variables (e.g. in Docker).
If key_storage_path is configured, the command also writes the keys to a JSON file after each rotation (see key_storage_path below).
--reverse iterates through N previous keys, re-encrypting data back to each one in sequence, then sets the restored key as APP_KEY. It fails if fewer previous keys exist than the requested --steps.
encrypted_models
Map your Eloquent models to the array of attributes that use Laravel's encrypted cast. The key:generate command iterates these models, chunking through records and re-encrypting each listed field with the new APP_KEY.
Each entry's value must be a non-empty array of attribute names. Models that don't exist or have no fields defined are skipped with a warning; if all models are skipped the command exits with a failure.
key_storage_path
Absolute path to a JSON file where the current APP_KEY and all previous keys are persisted after each key rotation. This is useful in Docker environments where other containers (sidecars, backup services) need to read the latest keys without accessing .env.
Override via .env:
When set to a non-null path, each key:generate run (forward or reverse) writes a JSON file with this structure:
The parent directory is created automatically if it does not exist. Set to null (default) to disable.
Security warning: This file contains your encryption keys in plain text. Ensure the file has restrictive permissions (e.g.
chmod 600), the parent directory is not world-readable, and the file is never committed to version control. When using Docker, mount the path as atmpfsvolume or use Docker secrets to avoid persisting keys to disk.
Available commands
make:enum
Laravel has no built-in enum generator. This command creates a PHP enum in app/Enums/.
Example output for php artisan make:enum UserRole --backed=string --cases=Admin,Partner,User:
Sub-namespaces (e.g. Billing/InvoiceStatus) are placed under app/Enums/Billing/ with the correct namespace App\Enums\Billing; declaration.
make:repo
Creates a repository class in app/Repositories/ extending BaseRepository. Optionally binds it to an Eloquent model.
Example output for php artisan make:repo PostRepo --model=Post:
make:api-scaffold
Scaffolds a full API controller, repository, resource, and resource collection for a given name.
Files generated:
app/Http/Controllers/Api/{Name}Controller.phpapp/Repositories/{Name}Repo.phpapp/Http/Resources/{Name}Resource.phpapp/Http/Resources/Collections/{Name}ResourceCollection.php
When --no-route is omitted, the command also registers a GET /v1/{prefix} route inside the throttle:120,1 group in routes/api.php. The prefix defaults to the kebab-case plural of the name (e.g. currencies for Currency).
make:resource-full
Creates an API Resource and its Resource Collection. Can inspect an existing model to pre-fill the toArray() fields.
Files generated:
app/Http/Resources/{Name}.phpapp/Http/Resources/Collections/{Name}Collection.php
When --with-relationships is used, the command inspects the model's public methods returning Eloquent Relation instances, adds relation lines to toArray(), generates missing related resource classes, and adds the necessary use imports.
model:relations
Lists all Eloquent relationships defined in a model class by inspecting method return types.
Example output:
If the model extends a base model in App\Models\Base\, relationships from both the parent and child are listed. Non-existent models produce an error message.
model:prune-orphaned
Scans one or more model directories and reports any model files that have no backing database table and no references anywhere in the codebase. By default it only lists candidates; pass --delete to remove them.
The directories scanned when no --path is given are controlled by model_scan_paths in the published config file (see Configuration).
A model is considered orphaned only when both conditions are true:
Schema::hasTable()returnsfalsefor its table- No other
.phpfile under the search path (defaultapp/) references the class by name or fully-qualified class name
Non-Eloquent PHP files (plain classes, interfaces, traits) found in the model directories are silently skipped. Missing directories produce a warning and are skipped; the command only fails when every configured path is missing.
Adding new commands
- Create a class in
src/Commands/using namespaceMasgeek\ArtisanToolkit\Commands.- To override a built-in: extend the original command class and change the behaviour.
- To add a new command: extend
Illuminate\Console\Commandas normal.
- Add it to the appropriate section in
config/artisan-toolkit.php(overridesorcommands). - The service provider registers it automatically when enabled.
License
MIT