How to make {{asset ('/css/app.css')}} in Lumen?

In Lumen, I can do this in my blade template:

{{ url('/css/app.css') }} 

In Laravel I could do

 {{ asset('/css/app.css') }} 

Is the URL helper everything I have to work with in Lumen?

+6
source share
2 answers

Check out the source code for Lumen UrlGenerator , the Lumen framework only supports url and route helpers. Of course, you can write an asset helper if you want.

+7
source

There was the same problem, moving from laravel to lumen. As @ hieu-le said, I made a helper helper as shown below.

 if (!function_exists('urlGenerator')) { /** * @return \Laravel\Lumen\Routing\UrlGenerator */ function urlGenerator() { return new \Laravel\Lumen\Routing\UrlGenerator(app()); } } if (!function_exists('asset')) { /** * @param $path * @param bool $secured * * @return string */ function asset($path, $secured = false) { return urlGenerator()->asset($path, $secured); } } 
+6
source

Source: https://habr.com/ru/post/987243/


All Articles