recca0120/终端

在Web应用程序中运行laravel artisan命令

v1.12.2 2024-06-21 12:06 UTC

README

Donate

Laravel终端

StyleCI Build Status Total Downloads Latest Stable Version Latest Unstable Version License Monthly Downloads Daily Downloads Scrutinizer Code Quality Code Coverage

安装

composer require recca0120/terminal --dev

或者

将Presenter添加到您的composer.json文件中

"require-dev": {
    "recca0120/terminal": "^1.6.8"
}

现在,从您的项目根目录运行composer update命令

composer update

注册包

app/config/app.php中包含服务提供者。服务提供者对于生成器 artisan 命令是必需的。

'providers' => [
    ...
    Recca0120\Terminal\TerminalServiceProvider::class,
    ...
];

发布

artisan vendor:publish --provider="Recca0120\Terminal\TerminalServiceProvider"

URL

https:///path/to/terminal

配置

return [
    'enabled'    => env('APP_DEBUG'),
    'whitelists' => ['127.0.0.1', 'your ip'],
    'route'     => [
        'prefix'     => 'terminal',
        'as'         => 'terminal.',
        // if you use laravel 5.1, remember to remove web middleware
        'middleware' => ['web'],
        // if you need auth, you need use web and auth middleware
        // 'middleware' => ['web', 'auth']
    ],
    'commands' => [
        \Recca0120\Terminal\Console\Commands\Artisan::class,
        \Recca0120\Terminal\Console\Commands\ArtisanTinker::class,
        \Recca0120\Terminal\Console\Commands\Cleanup::class,
        \Recca0120\Terminal\Console\Commands\Find::class,
        \Recca0120\Terminal\Console\Commands\Mysql::class,
        \Recca0120\Terminal\Console\Commands\Tail::class,
        \Recca0120\Terminal\Console\Commands\Vi::class,
        // add your command
    ],
];

可用命令

  • artisan
  • artisan tinker
  • 查找
  • mysql
  • 尾行显示
  • vi编辑器

查找

不支持完全,但您可以使用此功能删除文件(请检查文件权限)

find ./vendor -name tests -type d -maxdepth 4 -delete

添加您的命令

添加命令类

// src/Console/Commands/Mysql.php

namespace Recca0120\Terminal\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
use Recca0120\Terminal\Contracts\TerminalCommand;

class Inspire extends Command implements TerminalCommand
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'inspire';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Display an inspiring quote';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
    }
}

屏幕截图

可用命令

$ help

Available Commands

Artisan列表

$ artisan

Artisan List

迁移

$ artisan migrate --seed

Migrate

Artisan Tinker

$ artisan tinker

Tinker

MySQL

$ mysql
mysql> select * from users;

# change connection
mysql> use sqlite;
mysql> select * from users;

MySQL Command

查找命令

$ find ./ -name * -maxdepth 1

Find Command

查找和删除

$ find ./storage/logs -name * -maxdepth 1 -delete

Find and Delete

Vi编辑器

$ vi server.php

Vi Command

Vi Editor

Vi Save

尾行显示

$ tail
$ tail --line=1
$ tail server.php
$ tail server.php --line 5

Tail Command

清理

$ cleanup

Cleanup Command