Skip to content

Commit 5cb3316

Browse files
Add Tinker ClassAliasAutoloader register
1 parent 64a9413 commit 5cb3316

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/Loaders/LaravelLoader.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ public function __construct(string $path)
1818
$this->app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
1919
}
2020

21+
public function init(): void
22+
{
23+
parent::init();
24+
25+
$this->bootAliases();
26+
}
27+
2128
public function name(): string
2229
{
2330
return 'Laravel';
@@ -50,4 +57,22 @@ public function casters(): array
5057

5158
return $casters;
5259
}
60+
61+
private function bootAliases(): void
62+
{
63+
if (! class_exists(\Laravel\Tinker\ClassAliasAutoloader::class)) {
64+
return;
65+
}
66+
67+
$config = $this->app->make('config');
68+
69+
$path = \Illuminate\Support\Env::get('COMPOSER_VENDOR_DIR', $this->app->basePath().DIRECTORY_SEPARATOR.'vendor');
70+
71+
\Laravel\Tinker\ClassAliasAutoloader::register(
72+
$this->tinker->getShell(),
73+
$path.'/composer/autoload_classmap.php',
74+
$config->get('tinker.alias', []),
75+
$config->get('tinker.dont_alias', [])
76+
);
77+
}
5378
}

src/Tinker.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,9 @@ protected function cleanOutput(string $output): string
8585

8686
return trim($output);
8787
}
88+
89+
public function getShell(): Shell
90+
{
91+
return $this->shell;
92+
}
8893
}

0 commit comments

Comments
 (0)