4

I am installing a PHP script on my server as a test but I'm experiencing this error. I'm having trouble understanding what is wrong with the script code.

I enabled debug mode on the application and got this error message:

Call to undefined function Illuminate\Filesystem\symlink()

This is the code (The line that says: return symlink($target, $link); is the line where debug found the error):

public function copy($path, $target)
{
    return copy($path, $target);
}

/**
 * Create a symlink to the target file or directory. On Windows, a hard link is created if the target is a file.
 *
 * @param  string  $target
 * @param   string $link
 * @return void
 */
public function link($target, $link)
{
    if (!windows_os()) {
        return symlink($target, $link);
    }
    $mode = $this->isDirectory($target) ? 'J' : 'H';
    exec("mklink /{$mode} ".escapeshellarg($link).' '.escapeshellarg($target));
}

/**
 * Create a relative symlink to the target file or directory.
 *
 * @param  string  $target
 * @param   string $link
 * @return void
 */
public function relativeLink($target, $link){
    
}
starball
  • 20,030
  • 7
  • 43
  • 238
  • 2
    Try to use \symlink($target, $link) instead of symlink($target, $link), symlink is a function of php, so you need the escape it to not use the current namespace – Alex197 Dec 16 '21 at 15:06
  • @Alex197 php check global namespace automatically, as described here - https://www.php.net/manual/en/language.namespaces.fallback.php, also, according to namespace provided in error message, it's laravel vendor code – Anton Dec 16 '21 at 15:24
  • check (lZF) extension and also for more information [here](https://stackoverflow.com/questions/44929092/call-to-undefined-function-illuminate-filesystem-finfo-file) – moez sabri Nov 17 '22 at 23:36
  • check (lZF) extension and also for more information look [here](https://stackoverflow.com/questions/44929092/call-to-undefined-function-illuminate-filesystem-finfo-file) – moez sabri Nov 17 '22 at 23:38

3 Answers3

6

I have the same problem and the solution proved simple:

First, ssh to the server, navigate to your project folder, then delete the symlink from the public folder:

cd public
unlink storage

Finally, run the command to create the symlink manually (assuming we are still in public/):

ln -s ../storage/app/public storage
5

Seems you run it on a shared hosting, and some php functions are disabled by hosting provider for security reasons.

Anton
  • 728
  • 3
  • 8
  • 1
    oh, I was unaware of that. Yes, I run it on a shared hosting. – Pedro Henrique Dec 16 '21 at 15:27
  • Here is my php options. Does this have anything to do with this? https://imgur.com/a/5fw0pwS – Pedro Henrique Dec 16 '21 at 15:34
  • @PedroHenrique this is list of so-called extensions, it's ok, but you are interested in `disable_functions` configuration value, I'm not sure where it located in your panel. If `php.ini` is available for edit, you can find it there and set to empty string (`disable_functions=`) – Anton Dec 16 '21 at 15:41
  • I see. I'm getting in touch with my server support to talk to them about this. Thank you for your reply – Pedro Henrique Dec 16 '21 at 15:54
0

for me, I was using cPanel, the Jupiter theme. I went to "Select PHP version" then to the options tab and deleted the function from the disabled functions input and saved. then I ran php artisan storage:link and it worked perfectly (ps: I'm using Laravel) disabled functions input