PHP Classes

CSS Dispatcher: Compose CSS style sheets from multiple templates

Recommend this page to a friend!
  Info   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 354 All time: 6,948 This week: 462Up
Version License PHP version Categories
css-dispatcher 1.0GNU Lesser Genera...5.0PHP 5


This package can be used to compose CSS style sheets from multiple templates.

It can process one or more CSS templates that are actually PHP scripts.

The templates are processed by assigning PHP variables with template variable values and then the template script is executed and its output captured to get the final result.

A CSS template maybe evaluated conditionally depending on the type of browser accessing the current script.

The main class assembles the output of all CSS templates and may optimize them before outputting by removing needless white spaces.

Picture of khjk
Name: khjk <contact>
Classes: 1 package by
Country: Spain Spain
Age: ???
All time rank: 367697 in Spain Spain
Week rank: 344 Up9 in Spain Spain Up


CssDispatcher v0.1 =============================================================================== Welcome to CssDispatcher, a templated CSS processing library. It's very simple, you could have written it, but I did it for you ;-) and it's designed to be adapted to any framework or methodology you use. CssDispatcher provides you two simple classes: Css and CssDispatcher. Css class ------------------------------------------------------------------------------- The Css class wraps a stylesheet. You can instantiate it by specifying its file name: $layout = new Css('layout.css.php'); (I recommend you to use the ".css.php" suffix) So you can add variables to your template by dynamic typing: $layout->main_color = '#eee'; $layout->float = 'float: left'; You can instantiate a new CssDispatcher and add the previous template: $css = new CssDispatcher; $css->add($layout); And finally, of course you can dispatch the stylesheet: $css->render(); You can also add stylsheets for specific browsers, by adding a parameter to the Css class constructor: $ie_hacks = new Css('ie-hacks.css.php', Css::UA_IE6); So this stylesheet will be only added to Dispatcher output when the user's current browser is Internet Explorer 6. You can get the complete list of available user agents in the phpDocumentation (Css class constants). Caching, compression and other performance improvements ------------------------------------------------------------------------------- See "Server configurations" section. Server configurations ------------------------------------------------------------------------------- CssDispatcher does not provides a framework to manage all your stylesheets aspects. You can use the library in any web server that supports PHP, but I recommend (and CssLibrary was coded under) Apache. For caching and compression, CssDispatcher does not provide any specific solution, so you can use which you want: standard caching systems, manual compression (with header(), output buffers and gzip functions), server-specific solutions, etc. Personally, I like Apache's mod_deflate. To hide the CSS templates from the public access, you can use your favourite method, but I recommend .htacces deny: [Files *.css.php] deny from all [/Files] You can use URL-rewriting or any other method. You can even allow the public access to the templates (they will be compiled by PHP and they may cause errors, exposing probably insecure information about your web server). More information ------------------------------------------------------------------------------- CssDispatcher was written by Israel Viana. You can find more information about the library and its author at License ------------------------------------------------------------------------------- Remember that CssDispatcher is free software under the terms of the GNU Lesser General Public License (see LICENSE file for the complete license terms).

  Files folder image Files  
File Role Description
Plain text file class.Css.php Class Css class (auxiliar)
Plain text file class.CssDispatcher.php Class Main class
Accessible without login Plain text file example.css.php Aux. templated CSS
Accessible without login Plain text file example.php Example Example of CssDispatcher
Accessible without login Plain text file example2.css.php Aux. Another example of templated CSS
Accessible without login Plain text file INSTALL Doc. Installation instructions
Accessible without login Plain text file LICENSE Lic. LGPL License text
Accessible without login Plain text file README Doc. Some important information

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:6,948
This week:462Up