Assets not referencing to public folder (Laravel)

后端 未结 4 1638
鱼传尺愫
鱼传尺愫 2020-12-06 10:59

I have the public folder inside my laravel project and I have some js and css files inside it.

I\'m using the asset function and even though it\'s referencing to th

4条回答
  •  再見小時候
    2020-12-06 11:31

    I was having same problem. This is due to moving of .htaccess file from public to root of the project in order to serve localhost/project rather than localhost/project/laravel. And needed to use public as well in the asset:

    
    

    Or, modify the asset function from /Illuminate/Foundation/helpers.php

    if (! function_exists('asset')) {
        /**
         * Generate an asset path for the application.
         *
         * @param  string  $path
         * @param  bool    $secure
         * @return string
         */
        function asset($path, $secure = null)
        {
            return app('url')->asset("public/".$path, $secure);
        }
    }
    

    The preceding method is not good way. Anyway this would have been easier if there was config for setting asset path.

提交回复
热议问题