Bhargav Raviya
Bhargav Raviya

Reputation: 409

Laravel Package Development - How To Public Path Access in URL

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.

Upvotes: 0

Views: 83

Answers (2)

OmidDarvishi
OmidDarvishi

Reputation: 650

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

}

Upvotes: 0

Raviya Technical
Raviya Technical

Reputation: 21

Go .env File

APP_URL=http://127.0.0.1:8000

Using Config Path

return config('app.url').'/images/avatar-male.png';

Upvotes: 0

Related Questions