Forked from owenvoke/LaravelZeroTinkerwellDriver.php
Created
October 28, 2024 20:38
-
-
Save garyblankenship/8d2a01f884fb1a2dbb033f048888eb95 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