| Server IP : 127.0.1.1 / Your IP : 216.73.216.152 Web Server : Apache/2.4.52 (Ubuntu) System : Linux bahcrestlinepropertiesllc 5.15.0-113-generic #123-Ubuntu SMP Mon Jun 10 08:16:17 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/bahcrestline/core/vendor/laravel/tinker/src/Console/ |
Upload File : |
<?php
namespace Laravel\Tinker\Console;
use Illuminate\Console\Command;
use Laravel\Tinker\ClassAliasAutoloader;
use Psy\Configuration;
use Psy\Shell;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
class TinkerCommand extends Command
{
/**
* Artisan commands to include in the tinker shell.
*
* @var array
*/
protected $commandWhitelist = [
'clear-compiled', 'down', 'env', 'inspire', 'migrate', 'optimize', 'up',
];
/**
* The console command name.
*
* @var string
*/
protected $name = 'tinker';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Interact with your application';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$this->getApplication()->setCatchExceptions(false);
$config = new Configuration([
'updateCheck' => 'never',
]);
$config->getPresenter()->addCasters(
$this->getCasters()
);
$shell = new Shell($config);
$shell->addCommands($this->getCommands());
$shell->setIncludes($this->argument('include'));
if (isset($_ENV['COMPOSER_VENDOR_DIR'])) {
$path = $_ENV['COMPOSER_VENDOR_DIR'];
} else {
$path = $this->getLaravel()->basePath().DIRECTORY_SEPARATOR.'vendor';
}
$path .= '/composer/autoload_classmap.php';
$config = $this->getLaravel()->make('config');
$loader = ClassAliasAutoloader::register(
$shell, $path, $config->get('tinker.alias', []), $config->get('tinker.dont_alias', [])
);
if ($code = $this->option('execute')) {
$shell->execute($code);
$loader->unregister();
return 0;
}
try {
$shell->run();
} finally {
$loader->unregister();
}
return 0;
}
/**
* Get artisan commands to pass through to PsySH.
*
* @return array
*/
protected function getCommands()
{
$commands = [];
foreach ($this->getApplication()->all() as $name => $command) {
if (in_array($name, $this->commandWhitelist)) {
$commands[] = $command;
}
}
$config = $this->getLaravel()->make('config');
foreach ($config->get('tinker.commands', []) as $command) {
$commands[] = $this->getApplication()->resolve($command);
}
return $commands;
}
/**
* Get an array of Laravel tailored casters.
*
* @return array
*/
protected function getCasters()
{
$casters = [
'Illuminate\Support\Collection' => 'Laravel\Tinker\TinkerCaster::castCollection',
'Illuminate\Support\HtmlString' => 'Laravel\Tinker\TinkerCaster::castHtmlString',
];
if (class_exists('Illuminate\Database\Eloquent\Model')) {
$casters['Illuminate\Database\Eloquent\Model'] = 'Laravel\Tinker\TinkerCaster::castModel';
}
if (class_exists('Illuminate\Foundation\Application')) {
$casters['Illuminate\Foundation\Application'] = 'Laravel\Tinker\TinkerCaster::castApplication';
}
return $casters;
}
/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return [
['include', InputArgument::IS_ARRAY, 'Include file(s) before starting tinker'],
];
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return [
['execute', null, InputOption::VALUE_OPTIONAL, 'Execute the given code using Tinker'],
];
}
}