0

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.

3
  • Probably, assets should be published first? Try it out Commented Apr 16, 2023 at 10:57
  • You can try to use public_path() Commented Apr 16, 2023 at 11:33
  • what is "not working" about the asset function? Commented Apr 16, 2023 at 13:44

2 Answers 2

0

Go .env File

APP_URL=http://127.0.0.1:8000

Using Config Path

return config('app.url').'/images/avatar-male.png';
Sign up to request clarification or add additional context in comments.

1 Comment

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.
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);
}

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.