Giter VIP home page Giter VIP logo

artisan-gui's Introduction

This package now in very slow development. It's not abandoned, you can still use it.

Currently, started development of the new package. #34

Artisan GUI

:artisan gui

Packagist License Packagist Version Packagist Downloads Packagist PHP Version Support GitHub code size in bytes

Simple but yet powerful library for running some artisan commands.

Requirements

  • Laravel 8.*
  • php ^7.3

Installation

Just install package:

composer require infureal/artisan-gui

Installing 2.0.0@beta

composer require infureal/artisan-gui:2.0.0@beta

Vendor publishing

By default package has predefined config and inline styles and scripts. Since version 1.4 you can publish vendors like css and js files in vendor/artisan-gui:

php artisan vendor:publish --provider="Infureal\Providers\GuiServiceProvider"

Publish only config:

php artisan vendor:publish --tag="artisan-gui-config"

Publish only styles and scripts:

php artisan vendor:publish --tag="artisan-gui-css-js"

Running command

By default, you can access this page only in local environment. If you wish you can change local key in config.

Simply go to http://you-domain.com/~artisan and here we go! Select needed command from list, fill arguments and options/flags and hit run button.

What's new in v2

  • Moved to SPA/Vue
  • UI changed to more readable (IMHO)
  • Implementing search (with new design it's hard to find some command without search)
  • Added permission field to config (for more flexible adjustment)
  • Added array option fields

Configuration

Default config is:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Middleware list for web routes
    |--------------------------------------------------------------------------
    |
    | You can pass any middleware for routes, by default it's just [web] group
    | of middleware.
    |
    */
    'middlewares' => [
        'web',
//        'auth'
    ],

    /*
    |--------------------------------------------------------------------------
    | Route prefix
    |--------------------------------------------------------------------------
    |
    | Prefix for gui routes. By default url is [/~artisan-gui].
    | For your wish you can set it for example 'my-'. So url will be [/my-artisan-gui].
    |
    | Why tilda? It's selected for prevent route names correlation.
    |
    */
    'prefix' => '~',

    /*
    |--------------------------------------------------------------------------
    | Home url
    |--------------------------------------------------------------------------
    |
    | Where to go when [home] button is pressed
    |
    */
    'home' => '/',

    /*
    |--------------------------------------------------------------------------
    | Only on local
    |--------------------------------------------------------------------------
    |
    | Flag that preventing showing commands if environment is on production
    |
    */
    'local' => true,
    
    /*
    |--------------------------------------------------------------------------
    | List of command permissions
    |--------------------------------------------------------------------------
    |
    | Specify permissions to every single command. Can be a string or array
    | of permissions
    |
    | Example:
    |   'make:controller' => 'create-controller',
    |   'make:event' => ['generate-files', 'create-event'],
    |
    */
    'permissions' => [
    ],
    
    /*
    |--------------------------------------------------------------------------
    | List of commands
    |--------------------------------------------------------------------------
    |
    | List of all default commands that has end of execution. Commands like
    | [serve] not supported in case of server side behavior of php.
    | Keys means group. You can shuffle commands as you wish and add your own.
    |
    */
    'commands' => [
        // ...
    ]

];

Issues

If have any issue please write me.

artisan-gui's People

Contributors

catzilla avatar infureal avatar marispro avatar saineshmamgain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

artisan-gui's Issues

404 on ~/artisan

Laravel: 8.54
PHP: 7.4
artisan-gui 2.0.0@beta

Hi there,

Just installed this in my project:

  • composer require infureal/artisan-gui:2.0.0@beta
  • php artisan vendor:publish --tag="artisan-gui-config"
  • set local to false
  • enable auth middleware
  • prefix => '~'

When visiting localhost:3000/~artisan of localhost:3000/~artisan-gui it just throws a 404. I checked my route list and it doesn't contain anything related to artisan-gui. Am I missing something?

Thanks in advance. Great project :)

Array option problems

Hello,

Thank you for this great package ! It seems that that the array options haven't been taken into account (https://laravel.com/docs/8.x/artisan#option-arrays)

I managed to add my own command in the config, and it shows in the interface. However, I'm running into a problem with array options, because I can have several options for the same command.

My command migrates many different migration files to different external databases at the same time, here's what it looks like :

protected $signature = 'migrate:custom {artisanCommand : artisan command (migrate, migrate:rollback ...)} {--connection=* : database connection to migrate}';

Usage:

php artisan migrate:custom migrate --connection=databaseconnect1 --connection=databaseconnect2

To fix the backend I just made a quick change to GuiController:34 (and I can run the command several times)

    foreach ($data as $key => $value) {
        if ($command->getDefinition()->hasOption($key)) {
            $keyParams = "--{$key}";
            if ($command->getDefinition()->getOption($key)->isArray()) {
                $params[$keyParams][] = $value;
            } else {
                $params[$keyParams] = $value;
            }
        } else {
            $params[$key] = $value;
        }
    }

For the front-end it would be nice to have another field added once the first one is filled in, or to be able to differentiate arrays some other way :)

Limit access to specific users

Maybe it would be possible that if, when in production, it would only allow certain users to access the routes?

this would make it really useful for people on shared hosting with no access to SSH

Allow list/run specific commands based on authorization

Hi,

It could be very nice to be able to only display/run commands depending on Gate authorization.

For example, the commands list from config file could be something like:

'commands' => [
    'group-name' => [
        'foo:bar',    // Ok for everyone (who can access artisan gui)
        'can-run-baz' => 'baz'// Only for users with permission 'can-run-baz'
    ]
]

It requires to read the list before building the gui panel. Something like:

use Gate;

class GuiController extends Controller {
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    function index() {
        $commands = array_filter(config('artisan-gui.commands', []), function ($command, $permission) {
            return is_string($permission) ? Gate::allows($permission) : true;
        },  ARRAY_FILTER_USE_BOTH);
        return view('gui::index', [
            'commands' => array_values($commands)
        ]);
    }

This is raw code just to get the idea, a method should retrieve the filtered commands.
Permission should also be checked before runningg the command.

This feature should not introduce any BC. I may provide a PR if you're ok with this.

SQL error on route:list

Get the following MySQL error on running route:list with no options selected:
SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'payload' at row 1 (SQL: update sessions set payload = YTo2OntzOjY6Il90b2tlbiI7czo0MDoidEM0V1BJZ0pUMm5OeFNZSnY4a21YbkEzaUVXSG5vaEhwbks0eXJQZyI7czo5OiJfcHJldmlvdXMiO2.... (data exceeds 32k characters)
Laravel 8.12 / MySQL 5.7
Runs ok with compact option selected

Custome commands availabel?

Hello, i want to add custom command to this package for example
nohup php artisan queue:work --daemon --tries=3 &
it's possible to run put this commands into this package?

suggestion

I am trying to build GUI for my Laravel package but the commands in my package asks questions and the the behavior of the package depends on the input of those questions now I am searching for a way to resolve this then I saw your package and I think maybe we can cooperate together to add this feature to your package.

any way If I find the way to do that I'll notice you maybe you can add it to your package

New package based on current

Hello there. ๐Ÿ‘‹
I have plans to rework this package, adding new features besides running commands.
First, I ask @Catzilla, @saineshmamgain to contact me if you are free to work together.

โ„น๏ธ This package is not abbandoned. As far as possible, I will fix bugs and improve functionality. But most of the time will be spent on a new package.

What are the plans for the new package:

  • Handling STDIN/STDOUT with somthing like ChildProcess and ReactPHP itself
  • Show more information about laravel app such as migration status etc.
  • Reworking UI/UX.
    • If you have good examples of UI, you can attach them.
  • Support for custom handlers and plugn support.
    • Need to thing about the architecture

Feel free to write your wishes in this issue.

Incorrect titles for camelCase attributes and options

Arguments and options in camelCase format does not displayed properly

Environment

PHP 8.0.3
Laravel 8.31.0
Artisan GUI dev-main

Screenshot

image

Code to reproduce

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class VarDump extends Command
{
    protected $signature = 'var:dump {userEmail}';

    protected $description = 'Test command';

    public function handle(): void
    {
    }
}

Solution

Convert names to snake case before using title() function of Str (pull request proposed)

Empty command groups remain in UI

If all commands in group was filtered by permissions, empty group still displays in UI

Environment

  • PHP 8.0.3
  • Laravel 8.31.0
  • Artisan GUI 2.0.0@beta

Screenshot

image

Solution

Unset empty group from response array (Pull request proposed)

Open side modal when click on command without args/options

Hey,

When you have a command without arguments or options, if you click on command, it should show the modal and force you to click on RUN, instead of running the command right away.

Right now if you click, shows only the "running icon"

image

It's danger without that. :D

Error HTTPS

image

return [

    /*
    |--------------------------------------------------------------------------
    | Middleware list for web routes
    |--------------------------------------------------------------------------
    |
    | You can pass any middleware for routes, by default it's just [web] group
    | of middleware.
    |
    */
    'middlewares' => [
        'web',
        'auth',
        'role:' . App\Enums\UserType::ADMIN,
    ],

    /*
    |--------------------------------------------------------------------------
    | Route prefix
    |--------------------------------------------------------------------------
    |
    | Prefix for gui routes. By default url is [/~artisan-gui].
    | For your wish you can set it for example 'my-'. So url will be [/my-artisan-gui].
    |
    | Why tilda? It's selected for prevent route names correlation.
    |
    */
    'prefix' => '~',

    /*
    |--------------------------------------------------------------------------
    | Home url
    |--------------------------------------------------------------------------
    |
    | Where to go when [home] button is pressed
    |
    */
    'home' => '/',

    /*
    |--------------------------------------------------------------------------
    | Only on local
    |--------------------------------------------------------------------------
    |
    | Flag that preventing showing commands if environment is on production
    |
    */
    'local' => false,

    /*
    |--------------------------------------------------------------------------
    | List of command permissions
    |--------------------------------------------------------------------------
    |
    | Specify permissions to every single command. Can be a string or array
    | of permissions
    |
    | Example:
    |   'make:controller' => 'create-controller',
    |   'make:event' => ['generate-files', 'create-event'],
    |
    */
    'permissions' => [
    ],

    /*
    |--------------------------------------------------------------------------
    | List of commands
    |--------------------------------------------------------------------------
    |
    | List of all default commands that has end of execution. Commands like
    | [serve] not supported in case of server side behavior of php.
    | Keys means group. You can shuffle commands as you wish and add your own.
    |
    */
    'commands' => [
        'laravel' => [
            'clear-compiled',
            'down',
            'up',
            'env',
            // 'help',
            'inspire',
            'list',
            'notifications:table',
            'package:discover',
            'schedule:run',
            // 'schema:dump',
            'session:table',
            // 'storage:link',
            // 'stub:publish',
            'auth:clear-resets',
            'tail',
        ],
        'optimize' => [
            'optimize',
            'optimize:clear',
        ],
        'cache' => [
            'cache:clear',
            'cache:forget',
            'cache:table',
            'config:clear',
            'config:cache',
        ],
        /*
        'database' => [
            'db:seed',
            'db:wipe',
        ],
        */
        'events' => [
            'event:cache',
            'event:clear',
            'event:generate',
            'event:list',
        ],
        /*
        'make' => [
            'make:cast',
            'make:channel',
            'make:command',
            'make:component',
            'make:controller',
            'make:event',
            'make:exception',
            'make:factory',
            'make:job',
            'make:listener',
            'make:mail',
            'make:middleware',
            'make:migration',
            'make:model',
            'make:notification',
            'make:observer',
            'make:policy',
            'make:provider',
            'make:request',
            'make:resource',
            'make:rule',
            'make:seeder',
            'make:test',
        ],
        */
        'migrate' => [
            // 'migrate',
            // 'migrate:fresh',
            // 'migrate:install',
            // 'migrate:refresh',
            // 'migrate:reset',
            // 'migrate:rollback',
            'migrate:status',
        ],
        /*
        'queue' => [
            'queue:batches-table',
            'queue:clear',
            'queue:failed',
            'queue:failed-table',
            'queue:flush',
            'queue:forget',
            'queue:restart',
            'queue:retry',
            'queue:retry-batch',
            'queue:table',
        ],
        */
        'route' => [
            'route:cache',
            'route:clear',
            'route:list',
        ],
        'view' => [
            'view:cache',
            'view:clear',
        ],
        'backup' => [
            'backup:clean',
            'backup:list',
            'backup:monitor',
            // 'backup:run',
        ],
        'responsecache' => [
            'responsecache:clear',
        ],
        'opcache' => [
            'opcache:clear',
            'opcache:compile',
            'opcache:config',
            'opcache:status',
        ],
        'schedule-monitor' => [
            'schedule-monitor:list',
        ],
    ],

];

Incorrect display of tables in command

Tables are broken due to incorrect handling of spaces

Environment

  • PHP 8.0.3
  • Laravel 8.31.0
  • Artisan GUI 2.0.0@beta

Screenshot

image

Code to reproduce

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class VarDump extends Command
{
    protected $signature = 'var:dump';

    protected $description = 'Test command';

    public function handle(): void
    {
        $this->table([], [
            ['User email', 'user@localhost'],
            ['User ID', 1],
            ['Some another row 1', 'xxxxx'],
            ['Some another row 2', 'yyyyyyyyyyy'],
        ]);
    }
}

Solution

Display command output with white-space: pre; (Pull request proposed)

Support Lumen

first of all, thank you for your package
it would be useful to have support for lumens as well

PHP Version

i tried to run the composer require infureal/artisan-gui command but i got this error

[InvalidArgumentException]
Package infureal/artisan-gui at version has a PHP requirement incompatible with your PHP version (7.2.33)

what is the solution for this

Tag version incompatibility with Plesk Composer

Im using Plesk (panel website admin) extension to manage composer packages.
It's gives me error with tag name 2.0.0@beta presumably by the @ .
Could you change next tag version to a name without @ .
I will try no notify Plesk plugin developer. Thanks.

Undefined constant STDIN when command is interactive

Hello

I encounter an issue (beta v2) while trying command with interactive question (using $this->ask() or variant of it). Do you plan to support this in the next version?

This code will produce an error

exception: "Error"
file: "/home/vagrant/code/platform/vendor/symfony/console/Helper/QuestionHelper.php"
line: 113
message: "Undefined constant \"STDIN\""

Code example to reproduce the issue :

class MyTestCommand extends Command
{
	protected $signature = 'test';
	protected $description = 'Test command';

	public function handle()
	{

		$this->ask('hello ? ');

		return 0;
	}
}

Laravel 10 Compatibility

Now that Laravel 10 is out, this package should be compatible with it.

There's already a PR created by Shift: #42

Thanks!

route:list

No action on clic run befor wait no display list
but in terminal is ok not in page

Version 1.4.1 doesn't work with laravel jetsream livewire stack

Hi,
Thanks for this great package, i discovered the latest version 1.4.1 is incompatible with laravel Jetstream livewire stack, I used jetstream and this package, it works great with version 1.3, but after update all packages, i got error 'Livewire\Exceptions\ComponentNotFoundException' Unable to find component: [profile.update-profile-information-form], the same message for all Laravel Jetstream livewire components.
It's took me 2 days to debug and finally found this issue related to this package and specially version 1.4.1, after came back to version 1.3 o this package my app works fine again.

Class "Str" not found

Class "Str" not found {"exception":"[object] (Error(code: 0): Class "Str" not found at /var/www/html/vendor/infureal/artisan-gui/src/Http/Controllers/GuiController.php:155)

Not displaying anymore

Hello,

I've been using artisan-gui for over a month now and I really like it. I wanted to try the beta and now I only get a blank page.
I tried removing and reinstalling the current version but there's the same issue.

Kind regards,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.