creative-syntax/artisan-ui
Run Laravel Artisan commands from a web-based UI on live servers, including shared hosting. Install, visit /{prefix}/artisan-ui, and execute common tasks (cache, migrations, controllers, more). Configurable route prefix/name, heading, and optional login/password protection.
Installation
composer require creative-syntax/artisan-ui
Publish the package assets (if needed):
php artisan vendor:publish --provider="CreativeSyntax\ArtisanUI\ArtisanUIServiceProvider" --tag="artisan-ui-views"
First Use Case Create a simple Artisan command with a UI:
php artisan make:command TestCommand
Modify the generated command (app/Console/Commands/TestCommand.php) to include UI support:
use CreativeSyntax\ArtisanUI\Traits\HasArtisanUI;
class TestCommand extends Command
{
use HasArtisanUI;
protected $signature = 'test:ui';
protected $description = 'A test command with UI';
public function handle()
{
$this->ui()->info('This is a UI-powered command!');
}
}
Run the command:
php artisan test:ui
Access the UI at /artisan-ui (default route).
routes/web.php (if not auto-loaded):
Route::get('/artisan-ui', [\CreativeSyntax\ArtisanUI\ArtisanUIController::class, 'index']);
config/artisan-ui.php:
'commands' => [
'test:ui' => [
'name' => 'Test Command',
'description' => 'A test command with UI',
],
],
Extend Commands with UI
Use the HasArtisanUI trait to enable UI integration:
use CreativeSyntax\ArtisanUI\Traits\HasArtisanUI;
class MyCommand extends Command
{
use HasArtisanUI;
// Command logic...
}
The trait adds $ui property and ui() helper method.
UI Interaction Methods Leverage UI-specific methods in your command:
public function handle()
{
$this->ui()->success('Operation completed!');
$this->ui()->warning('This is a warning message.');
$this->ui()->error('Something went wrong.');
$this->ui()->input('Enter value:', $default = 'default');
}
Dynamic UI Forms
For interactive commands, use the ui()->form() method:
public function handle()
{
$data = $this->ui()->form([
'name' => 'text',
'age' => 'number',
]);
$this->info('Received: ' . json_encode($data));
}
Integration with Laravel Blade Customize the UI view by publishing assets and extending:
php artisan vendor:publish --tag="artisan-ui-views"
Override resources/views/vendor/artisan-ui/index.blade.php.
Command Registration
Automatically discover commands via HasArtisanUI trait. Manually register in config/artisan-ui.php if needed:
'commands' => [
'my:custom-command' => [
'name' => 'Custom Command',
'description' => 'Does something amazing.',
],
],
UI State Management
Pass data to the UI via ui()->setData():
$this->ui()->setData(['key' => 'value']);
Access in Blade:
@if(isset($data['key']))
{{ $data['key'] }}
@endif
Conditional UI Logic
Use ui()->shouldRender() to conditionally show/hide UI elements:
if ($this->ui()->shouldRender()) {
$this->ui()->info('UI is active!');
}
Route Conflict
/artisan-ui route may conflict with existing routes. Rename in config/artisan-ui.php:
'route' => 'admin/artisan',
Trait Overhead
HasArtisanUI with other traits that modify $signature or $description dynamically, as it may cause UI metadata conflicts.CSRF Protection
app/Http/Kernel.php:
'web' => [
\App\Http\Middleware\VerifyCsrfToken::class,
// ...
],
Session Dependencies
Check UI Data Flow
dd($this->ui()->getData()) to inspect passed data in commands.Clear Cached Views
php artisan view:clear
Log UI Events
config/artisan-ui.php:
'debug' => env('APP_DEBUG', false),
storage/logs/laravel.log.Custom UI Components
resources/views/vendor/artisan-ui/components/.Command-Specific Views
php artisan vendor:publish --tag="artisan-ui-views" --force
resources/views/vendor/artisan-ui/commands/test-ui.blade.php.API Integration
ArtisanUI::execute() method to run commands programmatically and fetch UI data:
$result = ArtisanUI::execute('test:ui');
$uiData = $result->getUiData();
Localization
php artisan vendor:publish --tag="artisan-ui-lang"
resources/lang/en/artisan-ui.php.How can I help you explore Laravel packages today?