Skip to content

Instantly share code, notes, and snippets.

@mpociot
Created November 21, 2019 16:25
Show Gist options
  • Save mpociot/cfdb5c1308772eb9397b887fa3f0decd to your computer and use it in GitHub Desktop.
Save mpociot/cfdb5c1308772eb9397b887fa3f0decd to your computer and use it in GitHub Desktop.
Custom Tinkerwell drivers
<?php
namespace BeyondCode\Tinkerwell\Drivers;
class LaravelTinkerwellDriver extends TinkerwellDriver
{
public function canBootstrap($projectPath): bool
{
return file_exists($projectPath.'/public/index.php') &&
file_exists($projectPath.'/artisan');
}
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();
}
}
<?php
namespace BeyondCode\Tinkerwell\Drivers;
class WordpressTinkerwellDriver extends TinkerwellDriver
{
public function canBootstrap($projectPath): bool
{
return file_exists($projectPath . '/wp-load.php');
}
public function bootstrap($projectPath)
{
require $projectPath . '/wp-load.php';
}
public function getAvailableVariables(): array
{
return [
'__blog' => get_bloginfo()
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment