In Laravel pacakage development, the asset()
function is not working. How can I properly use it? I also need to get the URL path of the public folder.
Asked
Active
Viewed 40 times
0

double-beep
- 5,031
- 17
- 33
- 41

Bhargav Raviya
- 84
- 6
-
Probably, assets should be published first? Try it out – InDevX Apr 16 '23 at 10:57
-
You can try to use `public_path()` – xenooooo Apr 16 '23 at 11:33
-
what is "not working" about the `asset` function? – lagbox Apr 16 '23 at 13:44
2 Answers
0
Go .env File
APP_URL=http://127.0.0.1:8000
Using Config Path
return config('app.url').'/images/avatar-male.png';

Raviya Technical
- 21
- 3
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 20 '23 at 12:38
0
you can use
url('/');
or
use laravel helper function:
Generate an asset path for the application
if (! function_exists('asset')) {
/**
* Generate an asset path for the application.
*/
function asset($path, $secure = null)
{
return app('url')->asset($path, $secure);
}
}

OmidDarvishi
- 558
- 4
- 8