Skip to content

Instantly share code, notes, and snippets.

@owenvoke
Created February 28, 2020 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save owenvoke/e3bf8c7394826c2541d450a5b12b2853 to your computer and use it in GitHub Desktop.
Save owenvoke/e3bf8c7394826c2541d450a5b12b2853 to your computer and use it in GitHub Desktop.
A Tinkerwell driver for Laravel Zero.
<?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'),
];
}
}
@owenvoke
Copy link
Author

Installation (will not overwrite existing driver):

wget -nv -nc -P .tinkerwell https://gist.githubusercontent.com/owenvoke/e3bf8c7394826c2541d450a5b12b2853/raw/LaravelZeroTinkerwellDriver.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment