Created
November 21, 2019 16:25
-
-
Save mpociot/cfdb5c1308772eb9397b887fa3f0decd to your computer and use it in GitHub Desktop.
Custom Tinkerwell drivers
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 | |
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(); | |
} | |
} |
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 | |
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