1 year ago

Laravel Global Helper Functions not working

Posted 1 year ago by chrisffm

Hey there,

I am pretty new to Laravel and try to use the "asset" method, one of the helper functions which come with Laravel. But when I use the function, e.g. "echo asset('storage/file.txt');", I get the following error: "PHP Fatal error: Uncaught Error: Call to undefined function asset() in /Users/...."

However, when I click on the function in my IDE, I get redirected to the "asset" function in the helpers.php file in the "vendor/laravel/framework/src/Illuminate/Foundation" directory. Also the helpers.php is specified in the framework's autoload in "vendor/laravel/framework/composer.json".

Is there something I am missing like importing the functions? When looking in the global helper function documentation of Laravel, they use the functions right away.

Best, Christian

Please sign in or create an account to participate in this conversation.