Skip to content

Instantly share code, notes, and snippets.

@davidcraig davidcraig/css.php
Created Mar 31, 2017

What would you like to do?
PHP: CSS Asset Pipeline
$files = [
// Insert Files Here
$str = '';
function combine_file_contents($filename, $str)
if (file_exists($filename)) {
$str .= file_get_contents($filename) . "\r\n";
return $str;
} else {
return $str;
foreach($files as $style) {
$str = combine_file_contents($style, $str);
$ETag = sha1($str);
/* Set Headers */
header('Content-Type: text/css');
header('ETag: ' . $ETag);
/* Output CSS */
echo $str;

This comment has been minimized.

Copy link
Owner Author

commented Mar 31, 2017

Simply add css files you wish to source into the $files array, then you can <link rel="stylesheet" src="css.php" type="text/css" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.