-
-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use with laravel tinker? #571
Comments
I don't think so, unless it works with collecting artisan commands? Have you tried turning it on? |
I tried messing with the settings to see if that was the reason it wasn't working. I can confirm it doesn't log anything when using tinker with artisan commands enabled. I'd like to suggest it as a feature. Love the package anyway! |
I had a similar need. I solved it with a custom Psy-Shell command: use Psy\Command\ReflectingCommand;
use Psy\VarDumper\Presenter;
use Psy\VarDumper\PresenterAware;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class MonitorDb extends ReflectingCommand implements PresenterAware
{
private ?Presenter $presenter = null;
/**
* PresenterAware interface.
*
* @param Presenter $presenter
*/
public function setPresenter(Presenter $presenter): void
{
$this->presenter = $presenter;
}
/**
* {@inheritdoc}
*/
protected function configure(): void
{
$this
->setName('monitor_db')
->setAliases(['mdb', 'debug_db', 'ddb'])
->setDescription('Start monitoring database queries');
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
\DB::listen(function ($query) use ($output){
$data = [
'sql' => $query->sql,
'bindings' => $query->bindings,
'execution_time' => $query->time,
];
$output->writeln($this->presenter->present($data));
});
return 0;
}
} You need to load the command in your |
Would be useful to also have it working with Tinkerwell |
Is it possible to log the queries when testing with laravel tinker? If so, can you provide instructions on how to enable it? I reviewed the docs and searched the issues, I don't see any other mention of using Tinker.
The text was updated successfully, but these errors were encountered: