laravel / tinker

Powerful REPL for the Laravel framework.
https://laravel.com/docs/artisan#tinker
MIT License
7.32k stars 130 forks source link

Develop #175

Closed kenng closed 4 months ago

kenng commented 4 months ago

This pull request adds support for class_alias to Tinker's configuration.

Motivation: We created a model App\Models\Event, which conflicts with the events facade. As a result, instead of the Event model class being aliased, the events facade was aliased.

This solution allows users to map the conflicting class name to another class. For example, in config/tinker.php.

<?php

return [
    'class_alias' => [
        'AppEvent' => App\Models\Event::class,
    ],
];

Not sure if this should be merged into the 2.x branch or the develop branch?

kenng commented 4 months ago

Noticed that the test fails for PHP 7.4 and below because I am using named arguments in the function. Let me know if this should support older versions of PHP. Thanks.