PHP code example of laradic / service-provider

1. Go to this page and download the library: Download laradic/service-provider library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

laradic / service-provider example snippets


class MyServiceProvider extends \Illuminate\Support\ServiceProvider {
    public function boot(){
        // config: blade-extensions
        $publishPath = function_exists('config_path') ? config_path('blade_extensions.php') : base_path('config/blade_extensions.php');
        $this->publishes([ __DIR__ . '/../config/blade_extensions.php' => $publishPath ], 'config');
    
        // views: blade-ext
        $this->loadViewsFrom(__DIR__ . '/../resources/views', 'blade-ext');
        $this->publishes([ __DIR__ . '/../resources/views' => resource_path('views/vendor/blade-ext') ], 'views');
        
        // migrations
        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
        
        // translations
        $this->loadTranslationsFrom(__DIR__.'/../resources/trans', 'blade-ext');
        $this->publishes([__DIR__.'/../resources/trans' => resource_path('lang/vendor/blade-ext') ]);
        
        // assets
        $this->publishes([ __DIR__.'/../resources/assets' => public_path('vendor/blade-ext')], 'public');
    }

    public function register(){
        $this->mergeConfigFrom(__DIR__ . '/../config/blade_extensions.php', 'blade_extensions');
    }
}

class MyServiceProvider extends \Laradic\ServiceProvider\ServiceProvider {
    protected $configFiles = ['blade_extensions'];
    protected $viewDirs = ['views' => 'blade-ext'];
    protected $migrationDirs = ['migrations'];
    protected $translationDirs = ['trans' => 'blade-ext'];
    protected $assetDirs = ['assets' => 'blade-ext'];
} 

class MyServiceProvider extends \Laradic\ServiceProvider\ServiceProvider {
    // Will look for all commands inside the 'Console' directory relative to this service provider
    protected $findCommands = ['Console']; 
} 

class MyServiceProvider extends \Laradic\ServiceProvider\ServiceProvider {
    // Register by FQN
    protected $commands = [Console\MyCommand::class]; 
    // or by custom binding name  
    protected $commands = ['commands.my.command' => Console\MyCommand::class];  
}