Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
composer.lock
/phpunit.xml
.phpunit.result.cache
/.idea
4 changes: 2 additions & 2 deletions src/Console/TinkerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Illuminate\Console\Command;
use Illuminate\Support\Env;
use Laravel\Tinker\ClassAliasAutoloader;
use Laravel\Tinker\Shell\CustomShell;
use Psy\Configuration;
use Psy\Shell;
use Psy\VersionUpdater\Checker;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
Expand Down Expand Up @@ -56,7 +56,7 @@ public function handle()
$config->setRawOutput(true);
}

$shell = new Shell($config);
$shell = new CustomShell($config);
$shell->addCommands($this->getCommands());
$shell->setIncludes($this->argument('include'));

Expand Down
17 changes: 17 additions & 0 deletions src/Shell/CustomShell.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Laravel\Tinker\Shell;

use Psy\Shell;

class CustomShell extends Shell
{
protected function getDefaultLoopListeners(): array
{
$listeners = parent::getDefaultLoopListeners(); // TODO: Change the autogenerated stub

$listeners[] = new ShellLogListener();

return $listeners;
}
}
31 changes: 31 additions & 0 deletions src/Shell/ShellLogListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Laravel\Tinker\Shell;

use Psy\ExecutionLoop\AbstractListener;
use Psy\Shell;

class ShellLogListener extends AbstractListener
{
/**
* Listen for code execution.
*
* @param \Psy\Shell $shell
* @param string $code
* @return void
*/
public function onExecute(Shell $shell, $code)
{
\Log::debug('Tinker session code run', ['code' => $code]);

Check failure on line 19 in src/Shell/ShellLogListener.php

View workflow job for this annotation

GitHub Actions / tests / Static Analysis

Call to static method debug() on an unknown class Log.
}

/**
* Determines if this log listener is supported.
*
* @return bool
*/
public static function isSupported(): bool
{
return true; //implement a proper check
}
}
Loading