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

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


Had the same problem, moving from laravel to lumen. As @hieu-le says, I made an asset helper as 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);    }}


Have look at Lumen UrlGenerator source code, the Lumen framework supports just url and route helpers. Of course, you can write the asset helper if you want.