Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rocky's avatar
Level 1

Extend Laravel for {{}} in js,css and php files

Hello,

i've got a quick question.

Is it possible to extend Laravel to use the {{ URL::to() }} {{ URL:asset() }} etc which can be done by {{}} also in blain .php files, .js and .css files? Actually it's just working in .blade.php files.

Thanks

0 likes
3 replies
willvincent's avatar

The short answer is no because the blade files aren't served directly as static assets the way JS and CSS files are, they're compiled into more basic php templates, which are still not served directly because dynamic data has to be injected into them... but js and css files are served directly by the webserver, not parsed by php.

willvincent's avatar

I think the real question to be asked here is why? What are you hoping to achieve by using blade syntax in js and css files.. most likely there's a better solution.

Please or to participate in this conversation.