Search code examples
laravelmulti-tenantlaravel-5.6

How to create laravel custom storage:link?


How to create laravel custom storage:link?

I would like to point project/public/storage >> project/storage/app/tenancy/tenants


Solution

  • At this moment it is not possible to customize the path with this command. I looked at the source code and couldn't find any hints regarding to this issue.

    The simplest thing you can do is make the symbolic link yourself. The only thing this command does is create that symlink with PHP. This is the source code:

    if (! windows_os()) {
        return symlink($target, $link);
    }
    
    $mode = $this->isDirectory($target) ? 'J' : 'H';
    
    exec("mklink /{$mode} \"{$link}\" \"{$target}\"");
    

    If you really need to make a command for it. You can create your own. If you want to see how Taylor did it, you can look in the following file:

    vendor/laravel/framework/src/Illuminate/Foundation/Console/StorageLinkCommand.php