Created
February 28, 2020 09:55
-
-
Save owenvoke/e3bf8c7394826c2541d450a5b12b2853 to your computer and use it in GitHub Desktop.
A Tinkerwell driver for Laravel Zero.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use LaravelZero\Framework\Application; | |
use Tinkerwell\ContextMenu\Label; | |
use Tinkerwell\ContextMenu\Submenu; | |
use Tinkerwell\ContextMenu\SetCode; | |
use Tinkerwell\ContextMenu\OpenURL; | |
class LaravelZeroTinkerwellDriver extends TinkerwellDriver | |
{ | |
public function canBootstrap($projectPath) | |
{ | |
return file_exists($projectPath . '/bootstrap/app.php') | |
&& is_dir($projectPath . '/vendor/laravel-zero/framework'); | |
} | |
public function bootstrap($projectPath) | |
{ | |
require_once $projectPath . '/vendor/autoload.php'; | |
$app = require_once $projectPath . '/bootstrap/app.php'; | |
$kernel = $app->make(\Illuminate\Contracts\Console\Kernel::class); | |
$kernel->bootstrap(); | |
} | |
public function contextMenu() | |
{ | |
return [ | |
Label::create('Detected Laravel Zero v'.Application::VERSION), | |
Submenu::create('Commands', collect(Artisan::all())->map(static function ($command, $key) { | |
return SetCode::create($key, "Artisan::call('{$key}', []);\nArtisan::output();"); | |
})->values()->toArray()), | |
OpenURL::create('Documentation', 'https://laravel-zero.com/docs/introduction'), | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation (will not overwrite existing driver):