src/Commands/initModuleBackendCommand.php
/**
     * Execute the console command.
     *
     * @return int
     */
Execute the console command.
@return int
Execute the console command . @return int
public function handle()
    {
        $path = app_path('ModuleBackend');
        if (file_exists($path)) {
            $this->info('Direktori ModuleBackend sudah ada. Gagal melakukan inisialisasi');
            return false;
        }
        mkdir($path);
        copy(
            __DIR__ . DIRECTORY_SEPARATOR . 'Stubs' . DIRECTORY_SEPARATOR . 'Backend' . DIRECTORY_SEPARATOR . 'moduleBackendServiceProvider.php', 
            $path . DIRECTORY_SEPARATOR . 'moduleBackendServiceProvider.php'
        );
        $helperPath = app_path('Helpers');
        if (!is_dir($helperPath)) {
            mkdir($helperPath);
        }
        $stubHelperPath = __DIR__ . DIRECTORY_SEPARATOR . 'Stubs' . DIRECTORY_SEPARATOR . 'Backend' . DIRECTORY_SEPARATOR . 'Helpers' . DIRECTORY_SEPARATOR;
        copy(
            $stubHelperPath . 'ResponseFormatter.php',
            $helperPath . DIRECTORY_SEPARATOR . 'ResponseFormatter.php'
        );
        $stubHelperPath = __DIR__ . DIRECTORY_SEPARATOR . 'Stubs' . DIRECTORY_SEPARATOR . 'Backend' . DIRECTORY_SEPARATOR . 'Helpers' . DIRECTORY_SEPARATOR;
        copy(
            $stubHelperPath . 'LoggerHelper.php',
            $helperPath . DIRECTORY_SEPARATOR . 'LoggerHelper.php'
        );
        $stubHelperPath = __DIR__ . DIRECTORY_SEPARATOR . 'Stubs' . DIRECTORY_SEPARATOR . 'Backend' . DIRECTORY_SEPARATOR . 'Helpers' . DIRECTORY_SEPARATOR;
        copy(
            $stubHelperPath . 'CurrencyHelper.php',
            $helperPath . DIRECTORY_SEPARATOR . 'CurrencyHelper.php'
        );
        $this->info('Modul backend berhasil diinisialisasi');
        $this->info('Selanjutnya Tambahkan \'App\ModuleBackend\moduleBackendServiceProvider::class\' pada file config/app.php');
        return false;
    }
public function handle ( ) { $ path = app_path ( 'ModuleBackend' ) ; if ( file_exists ( $ path ) ) { $ this -> info ( 'Direktori ModuleBackend sudah ada. Gagal melakukan inisialisasi' ) ; return false ; } mkdir ( $ path ) ; copy ( __DIR__ . DIRECTORY_SEPARATOR . 'Stubs' . DIRECTORY_SEPARATOR . 'Backend' . DIRECTORY_SEPARATOR . 'moduleBackendServiceProvider.php' , $ path . DIRECTORY_SEPARATOR . 'moduleBackendServiceProvider.php' ) ; $ helperPath = app_path ( 'Helpers' ) ; if ( ! is_dir ( $ helperPath ) ) { mkdir ( $ helperPath ) ; } $ stubHelperPath = __DIR__ . DIRECTORY_SEPARATOR . 'Stubs' . DIRECTORY_SEPARATOR . 'Backend' . DIRECTORY_SEPARATOR . 'Helpers' . DIRECTORY_SEPARATOR ; copy ( $ stubHelperPath . 'ResponseFormatter.php' , $ helperPath . DIRECTORY_SEPARATOR . 'ResponseFormatter.php' ) ; $ stubHelperPath = __DIR__ . DIRECTORY_SEPARATOR . 'Stubs' . DIRECTORY_SEPARATOR . 'Backend' . DIRECTORY_SEPARATOR . 'Helpers' . DIRECTORY_SEPARATOR ; copy ( $ stubHelperPath . 'LoggerHelper.php' , $ helperPath . DIRECTORY_SEPARATOR . 'LoggerHelper.php' ) ; $ stubHelperPath = __DIR__ . DIRECTORY_SEPARATOR . 'Stubs' . DIRECTORY_SEPARATOR . 'Backend' . DIRECTORY_SEPARATOR . 'Helpers' . DIRECTORY_SEPARATOR ; copy ( $ stubHelperPath . 'CurrencyHelper.php' , $ helperPath . DIRECTORY_SEPARATOR . 'CurrencyHelper.php' ) ; $ this -> info ( 'Modul backend berhasil diinisialisasi' ) ; $ this -> info ( 'Selanjutnya Tambahkan \'App\ModuleBackend\moduleBackendServiceProvider::class\' pada file config/app.php' ) ; return false ; }
Execute the console command.
Execute the console command .
// validate directory // make parent directory // copy module service-provider // check and init helpers directory // copy response formatter helper // copy response logger helper // copy response currency helper