tinkerwellapp / drivers

All available Tinkerwell drivers
https://tinkerwell.app
MIT License
84 stars 34 forks source link

Inclusion of `bootstrap` method throws error #16

Closed mikeerickson closed 4 years ago

mikeerickson commented 4 years ago

I am testing a very simple driver, and when I include the bootstrap method, it causes an error when loading custom project.

image

If I remove the bootstrap method, everything works as expected.

The simple driver code (basically pulled from example below)

<?php

use Tinkerwell\ContextMenu\SetCode;

class CustomTinkerwellDriver extends LaravelTinkerwellDriver
{

    public function canBootstrap($projectPath)
    {
        var_dump("canBootstrap ${projectPath}");
        return true;
    }

    // if function is removed, all works as expected
    public function bootstrap($projectPath)
    {
    }

    public function contextMenu(): array
    {
        return array_merge(parent::contextMenu(), [
            SetCode::create('Find latest users', <<<EOT
User::latest()->first()
EOT
            ),
        ]);
    }

}
mpociot commented 4 years ago

The problem is that you are extending from the Laravel driver, but since you override the bootstrap method, you never call the origin driver's bootstrap code.

Either remove the method, or call the parent bootstrap method with your own custom code.