Nesquik27
Nesquik27

Reputation: 254

How to change path in the laravel config if It's located in the folder upper then public?

I have laravel 5 and config file in the config folder and My css located in the resources folder which is a same level with public folder where located index.php. Virtual Host Apache config looks to the public folder as a root site directory, but in this situation I cannot declare correct path from /public/index.php to the resources folder.

From one side I can try easy way and just relocate public folder into root of the laravel, but I don't like this way, any ideas?

Upvotes: 0

Views: 2107

Answers (2)

Mohammad Gitipasand
Mohammad Gitipasand

Reputation: 350

add this code in public/index.php

$app->bind('path.public', function() {
     return __DIR__;
});

Upvotes: 0

Loek
Loek

Reputation: 4135

Use resource_path('path/to/your/css')

https://laravel.com/docs/5.3/helpers#method-resource-path

EDIT

The most logical is to include your stylesheets in your public folder though. If you need to style a page, the style is public anyway. So why not put in the public folder. There's 2 options to do this:

  1. Do it manually by just copying/moving the files
  2. Use an automated tool like Gulp or Laravel's own Elixir, which provides a really easy way to copy your assets.

Upvotes: 1

Related Questions