获取所有Laravel Artisan命令以进行界面

时间:2018-08-07 10:29:54

标签: php laravel artisan

在命令行中使用php artisan时,将获得所有命令的列表。是否有机会以编程方式获取所有Laravel工匠命令?例如,我需要它在界面的选择字段中使用它。

5 个答案:

答案 0 :(得分:1)

要获取所有命令对象:

\Artisan::all()

要获取所有命令名称:

array_keys(\Artisan::all())

答案 1 :(得分:1)

use Illuminate\Contracts\Console\Kernel;
...
$commands = resolve(Kernel::class)->all();

答案 2 :(得分:0)

使用shell-exec命令。 http://php.net/manual/en/function.shell-exec.php

console.log()

答案 3 :(得分:0)

您可以像这样将它们放在您的路线中:

/* Displays a given OutputTable object in a dialog */
public static void displayHTMLOutput(OutputTable table) {

    /* Create modal dialog and JFXPanel */
    JDialog dialog = new JDialog((Window) null);
    JFXPanel jfxPanel = new JFXPanel();

    /* Add JFXPanel to dialog */
    dialog.add(jfxPanel);

    /* Configure the dialog */

    dialog.setModalityType(ModalityType.APPLICATION_MODAL);
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.setSize(1200, 800);

    /* Maps escape key to closing the dialog */
    key(dialog);

    /* sets an icon for the dialog */
    ImageIcon img = new ImageIcon("icons/report.png");
    dialog.setIconImage(img.getImage());

    /* Runs ons the JavaFX Application Thread at a later time */
    Platform.runLater(() -> {

        /* Create webview and bind to scene */
        WebView webView = new WebView();        
        jfxPanel.setScene(new Scene(webView));

        /* Load the html in a webview */
        webView.getEngine().loadContent(DisplayHtml.getOutputHTMLOutputTable("template.html", table));      

    });

    /* Do some actions on the dialog */
    dialog.setAlwaysOnTop(true);
    dialog.requestFocus();
    dialog.setLocationRelativeTo(null);
    dialog.setVisible(true);

    /* Test is now only printed to console when the dialog is closed */
    System.out.println("test");     
}

https://laravel.com/docs/5.0/artisan#calling-commands-outside-of-cli

答案 4 :(得分:0)

如果我正确理解该查询,则可以使用CLI(例如debian中的bash)执行以下操作:

  1. &&用于单个呼叫-每个后续呼叫将在上次演奏后进行,例如:

    php artisan migrate:fresh && php artisan fixtures:up && php artisan db:seed && php artisan serv

  2. 在.bash_profile中输入的
  3. 别名

    alias migrate = "php artisan migrate"

并在Laravel项目中使用命令migrate

信息:https://gist.github.com/JeffreyWay/5542264