Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create symlink for storage public folder for Lumen

Tags:

php

storage

lumen

I have used the following command to create symnlink for storage public folder for my project which I'm doing in Lumen . => php artisan storage:link

But I am getting this error in terminal =>

There are no commands defined in the "storage" namespace.

Another query is though I'm able to upload file in storage folder , how I'm able to access, I need some sample code for this. Kindly help.

like image 200
Soumik Chakraborty Avatar asked Dec 12 '17 12:12

Soumik Chakraborty


People also ask

What Artisan command that can create symbolic links configured for the application?

You can create a symlink via SSH by running the following command: ln -s /path/to/target /path/to/shortcut. It can also be created via a cronjob using the same command: You can also create a symlink using the PHP function.

What is php artisan storage Link?

php artisan storage:link. Once a file has been stored and the symbolic link has been created, you can create a URL to the files using the asset helper: echo asset('storage/file.txt'); You may configure additional symbolic links in your filesystems configuration file.

How do I access storage files in laravel?

How do I access storage files in Laravel? Laravel's filesystem configuration file is located at config/filesystems. php . Within this file, you may configure all of your filesystem "disks".

How to save file in Laravel?

How do I save a file in Laravel? Symlink public/storage to storage/app/public using php artisan storage:link. Upload file using $path = $request->file('avatar')->store('avatars');


2 Answers

I created by this unix command :

ln -s sourceforwhich symnlinkfolderpath e.g.:

ln -s /data/html/projectfolder/storage/app/public /data/html/projectfolder/public/storage

like image 74
Soumik Chakraborty Avatar answered Sep 25 '22 07:09

Soumik Chakraborty


This is for windows,

First of all run cmd with administrator if you are on another user not in admin and then go to your project's public path e.g. project/path/public.

Then run below command,

mklink /D "storage\" "E:absolute/static/path~/storage/app/public/"

For e.g.,

mklink /D "storage\" "E:/User Name/Work/My Projects/storage/app/public/"

Hopefully it will help for Lumen windows users.

like image 23
Jaydeep Mor Avatar answered Sep 25 '22 07:09

Jaydeep Mor