Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel - Generate CSS from database

is it possible with Laravel (latest) to generate an css file "on the fly" from custom css code from the database?
I've stored the custom css code in "custom_css" (longtext) in my mysql db.

I just thought that I could output it via blade:

<style type="text/css">{{$custom_css}}</style>  

But isn't there a possibility to generate a css "on the fly" and add it via link-tag?
Adding it via blade could extend my html code, I don't want that. I want a clean "html" (as much as possible).
Thanks!

like image 258
Marek123 Avatar asked Mar 19 '23 17:03

Marek123


1 Answers

Given your comments:

Route::get('/path/to/css', function() {
    // fetch your CSS and assign to $contents
    $response = Response::make($contents);
    $response->header('Content-Type', 'text/css');
    return $response;
});
like image 116
drmarvelous Avatar answered Mar 30 '23 09:03

drmarvelous