Skip to content

Commit 44ec49a

Browse files
committed
Add script header to output
1 parent a2656a7 commit 44ec49a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

index.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
/**
33
* Name: Combine Scripts
44
* Description: A simple PHP script to combine script assets
5-
* Version: 0.1.0
5+
* Version: 0.2.0
66
* Author: Daniel M. Hendricks
77
* GitHub: https://github.com/dmhendricks/php-combine-scripts
88
*/
99
use MatthiasMullie\Minify;
10-
$version = '0.1.0';
10+
$version = '0.2.0';
1111

1212
require( __DIR__ . '/vendor/autoload.php' );
1313

1414
// Load environmental configuration
1515
if( file_exists( '.env' ) ) {
1616
$dotenv = \Dotenv\Dotenv::create(__DIR__);
17-
$dotenv->load();
17+
$dotenv->load();
1818
}
1919

2020
// Set variables
@@ -76,16 +76,17 @@
7676
$output = $minifier->minify();
7777
}
7878

79-
$output = "/**\n * Combined by php-combine-scripts v{$version}.\n * More information: https://github.com/dmhendricks/php-combine-scripts\n */\n" . $output;
80-
81-
8279
}
8380

84-
// Send to browser
81+
// Add header to result
82+
$output = sprintf( "/**\n * %s by php-combine-scripts v%s.\n * More information: https://github.com/dmhendricks/php-combine-scripts\n */\n%s", $disable_minify ? 'Combined' : 'Minified', $version, $output );
83+
84+
// Set content type
8585
$content_type = 'text/plain';
8686
if( in_array( $type, [ 'js', 'css' ] ) ) {
8787
$content_type = $type == 'js' ? 'text/javascript' : 'text/css';
8888
}
8989

90+
// Output to browser
9091
header( "Content-Type: {$content_type}" );
9192
echo $output;

0 commit comments

Comments
 (0)