Laravel-modules: Create a new Disk

Created on 26 Mar 2018  路  3Comments  路  Source: nWidart/laravel-modules

I'm creating a file share module, and I want to know how to create an specific path to my directory as a disk, putting as default on Configconfig.php, and been overwrited by .env variable MODULE_DISK_PATH

Most helpful comment

It is possible to register disks within modules by creating a service provider that appends your config to the "filesystems.disks" option.

You can then add your own logic to this file (load your custom config, MODULE_DISK_PATH env variable etc...).

Basic example:

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $moduleName = 'mymodule';

        Config::set('filesystems.disks.' . $moduleName . '.disk1', [
            'driver' => 'local',
            'root' => storage_path('app/modules/' . $moduleName . '/disk1'),
            'visibility' => 'public',
        ]);
    }

All 3 comments

You can configure disks like in any laravel app, in the filesystems.php configuration file.

I'll close this due to inactivity.

It is possible to register disks within modules by creating a service provider that appends your config to the "filesystems.disks" option.

You can then add your own logic to this file (load your custom config, MODULE_DISK_PATH env variable etc...).

Basic example:

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $moduleName = 'mymodule';

        Config::set('filesystems.disks.' . $moduleName . '.disk1', [
            'driver' => 'local',
            'root' => storage_path('app/modules/' . $moduleName . '/disk1'),
            'visibility' => 'public',
        ]);
    }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

quentingosset picture quentingosset  路  4Comments

abiodunjames picture abiodunjames  路  5Comments

vdjkelly picture vdjkelly  路  4Comments

morningmemo picture morningmemo  路  3Comments

cyberbaseza picture cyberbaseza  路  4Comments