Skip to content

bdwilliams/Spassets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spassets - SlimPHP Asset Manager

TODO:

  • Twig Extension
  • Support for Less

Example:

index.php:

require 'vendor/autoload.php';

$assets = New \Spassets\Spassets();
$assets->minify = true;

$app->get('/', function () use ($app, $assets) {
	$css = $assets->printAssets('css', array('/css/bootstrap/bootstrap.min.css', '/css/bootstrap/bootstrap-responsive.min.css', '/css/custom.css'));
	$js = $assets->printAssets('js', array('/js/bootstrap/bootstrap.js', '/js/custom.js'));
    $app->render('index.html.twig', array('session' => $_SESSION, 'css' => $css, 'js' => $js));
});

index.html.twig:

<!DOCTYPE html>
<html>
  <head>
    <title>Your Page</title>
    {{ css|raw }}
  </head>
  <body>
    <h1>Hello, world!</h1>
    {{ js|raw }}
  </body>
</html>

Recommended:

Gzip your assets by putting this in your root .htaccess file:

<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
</ifmodule>

About

SlimPHP Asset Manager

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages