Laravel 5.5 Override vendor class

后端 未结 1 465
旧巷少年郎
旧巷少年郎 2020-12-16 05:42

I\'m trying to override (not extend) a vendor class. So whenever the vendor class gets called (within the vendor code), I want it to call my custom class.

It looks

相关标签:
1条回答
  • 2020-12-16 06:11

    So the solution was create a new ServiceProvider

    php artisan make:provider MyServiceProvider
    

    Which extended the Vendor service provider (found within config/app.php). Within that ServiceProvider, add my alias within the overridden Register method

     $loader->alias('Vendor\VendorName\Class', 'App\Vendor\MyCustomClass');
    
    0 讨论(0)
提交回复
热议问题