PHPackages                             thettler/laravel-console-toolkit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. thettler/laravel-console-toolkit

ActiveLibrary

thettler/laravel-console-toolkit
================================

This Package provides some usefully console features like the attribute syntax for arguments and options, validation, auto ask and casting.

0.2.0(2y ago)324.1k↓100%2[2 PRs](https://github.com/thettler/laravel-console-toolkit/pulls)MITPHPPHP ^8.1

Since Mar 1Pushed 2y ago1 watchersCompare

[ Source](https://github.com/thettler/laravel-console-toolkit)[ Packagist](https://packagist.org/packages/thettler/laravel-console-toolkit)[ Docs](https://github.com/thettler/laravel-console-toolkit)[ GitHub Sponsors](https://github.com/thettler)[ RSS](/packages/thettler-laravel-console-toolkit/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (14)Versions (6)Used By (0)

Laravel Console Toolkit
=======================

[](#laravel-console-toolkit)

[![Latest Version on Packagist](https://camo.githubusercontent.com/62156e0fd0706d53a4f07479d8d3df645e32a32f79729f1fb1a1c1e4f3a6f9bf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74686574746c65722f6c61726176656c2d636f6e736f6c652d746f6f6c6b69742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/thettler/laravel-console-toolkit)[![GitHub Tests Action Status](https://github.com/thettler/laravel-console-toolkit/actions/workflows/run-tests.yml/badge.svg)](https://github.com/thettler/laravel-console-toolkit/actions/workflows/run-tests.yml)[![GitHub Code Style Action Status](https://github.com/thettler/laravel-console-toolkit/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/thettler/laravel-console-toolkit/actions/workflows/php-cs-fixer.yml)[![PHPStan](https://github.com/thettler/laravel-console-toolkit/actions/workflows/phpstan.yml/badge.svg)](https://github.com/thettler/laravel-console-toolkit/actions/workflows/phpstan.yml)[![Total Downloads](https://camo.githubusercontent.com/c4a54995b57dfea7ddc81004fc89bc625df62336e1ac185f1bf920a6ecd5762c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74686574746c65722f6c61726176656c2d636f6e736f6c652d746f6f6c6b69742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/thettler/laravel-console-toolkit)[![PHP Version](https://camo.githubusercontent.com/f3580a0b65bb59f4015f70936237a6de725e7455cd3ebc9cd182b4ad9cfed301/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f74686574746c65722f6c61726176656c2d636f6e736f6c652d746f6f6c6b69743f7374796c653d666c61742d737175617265)](https://packagist.org/packages/thettler/laravel-console-toolkit)

[![Header Image](/.github/header_img.png)](/.github/header_img.png)

This package makes it even easier to write maintainable and expressive Artisan commands, with argument/option casting, validation and autoAsk. Also, it lets you define your arguments/options with simple properties and attributes for better ide support and static analysis. And all this with a single trait.

🤯 Features
----------

[](#-features)

All the features:

SupportNameDescription✅Laravel FeaturesSupports everything laravel can do✅Attribute SyntaxUse PHP-Attributes to automatically define your inputs based on types✅CastingAutomatically cast your inputs to Enums, Models, Objects or anything you want✅ValidationUse the Laravel Validator to validate the inputs from the console✅Auto AskIf the user provides an invalid value toolkit will ask again for a valid value without the need to run the command again✅Negatable OptionsOptions can be specified as opposites: --dry or --no-dry✅Option required ValueOptions can have required values💜 Support me
------------

[](#purple_heart--support-me)

Visit my blog on  or follow me on Social Media [Twitter @bitbench](https://twitter.com/bitbench)[Instagram @bitbench.dev](https://www.instagram.com/bitbench.dev/)

📦 Installation
--------------

[](#package--installation)

You can install the package via composer:

```
composer require thettler/laravel-console-toolkit
```

🔧 Usage
-------

[](#wrench--usage)

> 🗯️ Before you use this package you should already have an understanding of Artisan Commands. You can read about them [here](https://laravel.com/docs/8.x/artisan).

### A Basic Command

[](#a-basic-command)

To use the Toolkit you simply need to add the `UsesConsoleToolkit` trait inside your command.

Then add the `Thettler\LaravelConsoleToolkit\Attributes\ArtisanCommand` to the class to specify the name and other things like description, help, and so on.

The `ArtisanCommand` requires the `name` parameter to be set. This will be the name of the Command which you can use to call it from the commandline.

```
