1

We made a modulized app in laravel 5.0, So we want to get our css and js files from another directory (non public directory) such as a module directory. We searched the stacks and couldn't find any solution. How can we do that? Thanks

hint: the asset() function doesn't work except in public directory.

Abolfazl
  • 103
  • 1
  • 1
  • 10

2 Answers2

2

You have two options:

1.You can setup a route to serve files from your directory.

Route::get('assets/{filename}', function ($filename){
    $path =  'path_to_your_folder/'.$filename;

    $file = File::get($path);
    $type = File::mimeType($path);

    $response = Response::make($file, 200);
    $response->header("Content-Type", $type);

    return $response;
});

2.Make a symbolic link between the directories.

ln -s /path/to/your_assets_folder /path/to/public/assets

Got it from: this similar question

Community
  • 1
  • 1
Muhammet
  • 3,288
  • 13
  • 23
0

Use url function url('your_address')

paranoid
  • 6,799
  • 19
  • 49
  • 86