PHP code example of emir / laravel-webartisan

1. Go to this page and download the library: Download emir/laravel-webartisan library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

emir / laravel-webartisan example snippets


return [
    // Master switch
    'enabled' => env('WEBARTISAN_ENABLED', true),

    // Only available in these environments
    'enabled_environments' => ['local'],

    // URL prefix (accessible at /webartisan)
    'route_prefix' => env('WEBARTISAN_PREFIX', 'webartisan'),

    // Restrict to a specific domain
    'domain' => env('WEBARTISAN_DOMAIN', null),

    // Route middleware
    'middleware' => ['web'],

    // Gate-based authorization (see Security section)
    'gate' => null,

    // Only allow these commands (empty = all except blocked)
    'allowed_commands' => [],

    // Always block these commands
    'blocked_commands' => [
        'down', 'up', 'env', 'serve', 'tinker',
        'key:generate', 'migrate:fresh', 'migrate:reset',
        'db:wipe', 'db:seed', ...
    ],

    // Terminal theme: 'dark', 'light', 'monokai', 'dracula'
    'theme' => env('WEBARTISAN_THEME', 'dark'),
];

'enabled_environments' => ['local'],

use Illuminate\Support\Facades\Gate;

Gate::define('viewWebartisan', function ($user) {
    return in_array($user->email, [
        '[email protected]',
    ]);
});

'gate' => 'viewWebartisan',
'middleware' => ['web', 'auth'], // Add auth middleware

use Emir\Webartisan\Webartisan;

Webartisan::auth(function ($request) {
    return $request->user()?->isAdmin() ?? false;
});

// Only allow specific commands
'allowed_commands' => ['route:list', 'migrate:status', 'queue:*'],

// Block dangerous commands (supports wildcards)
'blocked_commands' => ['db:*', 'migrate:fresh', 'tinker'],
bash
php artisan webartisan:install
bash
# Config file
php artisan vendor:publish --tag=webartisan-config

# Frontend assets
php artisan vendor:publish --tag=webartisan-assets

# Blade views (for customization)
php artisan vendor:publish --tag=webartisan-views