Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Syndetic, an easy-to-use PHP asset preparation and delivery software, based on Assetic.
PHP
branch: master
Failed to load latest commit information.
Syndetic Implementation of SyndeticException.
cache Added custom directories.
config
js
less Added custom directories.
lib Added cssmin, Symfony Process Builder, improved component builder and…
.gitignore
.gitmodules Initial commit.
.htaccess
LICENSE Added License.
README.md Added submodules info to README.
autoloader.php
index.php Changed config to use "main"(.conf.php). Please create any configurat…

README.md

syndetic project status

Syndetic, an easy-to-use PHP asset preparation and delivery software, based on Assetic.

Description

Syndetic provides a simple way to serve assets (e.g. CSS or JavaScript files) through requesting them within the URL or configuring aliases for combining multiple files. In addition, it allows configuration of generators/compressors for pre- and post-progression of assets.

Setup

Simply deploy the whole repository into a directory that can be accessed through your web-server. You could either clone it right into a subdirectory of your web project or set up a new VirtualHost (e.g. sub-domain) for Syndetic. A sample Apache configuration for a stand-alone Syndetic could look like this:

<VirtualHost *:80>
        ServerName syndetic.local
        ServerAdmin webmaster@localhost

        DocumentRoot /mnt/hgfs/syndetic
        <Directory /mnt/hgfs/syndetic/>
                AllowOverride All
                Options Indexes FollowSymLinks MultiViews
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error_syndetic.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access_syndetic.log combined
</VirtualHost>
<VirtualHost *:443>
        ServerName syndetic.local
        ServerAdmin webmaster@localhost

        DocumentRoot /mnt/hgfs/syndetic
        <Directory /mnt/hgfs/syndetic/>
                AllowOverride All
                Options Indexes FollowSymLinks MultiViews
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error_syndetic.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access_syndetic.log combined

        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
        SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
</VirtualHost>

Within the directory /mnt/hgfs/syndetic you would have cloned this GitHub repository then. Make sure to have the submodules also initialized! Assetic itself is being used as a submodule!

Configuration

Next, Syndetic needs a configuration itself. Open the sample config in ./config/dev.conf.php and adapt it:

<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/JSMinPlus.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/cssmin.php';
use Assetic\Filter\LessFilter as CssGenerator;
use Assetic\Filter\CssRewriteFilter as CssRewriter;
use Assetic\Filter\CssMinFilter as CssCompressor;
use Assetic\Filter\JSMinPlusFilter as JsCompressor;
use Assetic\Filter\UglifyJs2Filter as JsUglifier;


$__CSSSRC_DIR__ = $_SERVER['DOCUMENT_ROOT'] . '/less';
// $__CSS_DIR__ = $_SERVER['DOCUMENT_ROOT'] . '/css';
$__JS__DIR__ = $_SERVER['DOCUMENT_ROOT'] . '/js';
$__CACHE_DIR__ = $_SERVER['DOCUMENT_ROOT'] . '/cache';
$__CACHE_CSS_DIR__ = $__CACHE_DIR__ . '/css';
$__CACHE_JS_DIR__ = $__CACHE_DIR__ . '/js';
$__BIN_DIR__ = $_SERVER['DOCUMENT_ROOT'] . '/bin';

// Global Paths, adapt to your needs
$__NODE_BIN_PATH__ = '/usr/local/bin/node';
$__NODE_PATH__ = '/usr/local/lib/node:/usr/local/lib/node_modules';
$__UGLIFYJS2_PATH__ = '/usr/local/bin/uglifyjs2';
$__JAVA_PATH__ = '/usr/bin/java'; //C:\Program Files (x86)\Java\jre1.6.0_22\bin\java.exe

return array(
  'devMode' => true,
  'timezone' => 'Europe/Berlin',
  'css' => array(
    'targetDir' => $__CSSSRC_DIR__,
    'fileExtension' => 'less',
    'cacheDir' => $__CACHE_CSS_DIR__,
    // 'generator' => array(new CssGenerator($__NODE_BIN_PATH__, explode(':', $__NODE_PATH__))),    
    'compressor' => array(new CssGenerator($__NODE_BIN_PATH__, explode(':', $__NODE_PATH__))),    
    'aliases' => array(
      'testalias' => array(
        'fileOne',
        'fileTwo',
        'fileThree'
      )
    )
  ),
  'js' => array(
    'targetDir' => $__JS__DIR__,
    'fileExtension' => 'js',
    'cacheDir' => $__CACHE_JS_DIR__,
    // 'compressor' => array(new JsUglifier($__UGLIFYJS2_PATH__, $__NODE_BIN_PATH__))
    // 'compressor' => array(new JsCompressor())
  ),
)

?>

The first few lines within this config require the add-on libraries for Assetic's filters to work. Next, there are definitions for several "uses", in order to have features like CSS generation (from SASS or LESS for example), CSS compression or JavaScript minification available. Then, several variables are being set, which contain paths to the external tools being used.

Last but not least, the actualy Syndetic configuration array follows-up:

  • devMode: (bool) turn development mode on and off. With devMode set to true, no caching is being used at all
  • timezone: (string) the timezone that's being used by the server Syndetic is running on
  • css or js: (array) definitions for CSS/JS assets

    • targetDir: (string) the directory in which the CSS/LESS/SASS/JS files are located
    • fileExtension: (strings) the file extension, e.g. "less", "sass", "css" or "js" - or whatever the files' extension is
    • cacheDir: (string) the directory where the asset cache should be stored into
    • generator: (array, containing AsseticFilter(s)) filters that should be applied on each file that's being requested separately
    • compressor: (array, containig AsseticFilter(s)) filters that should be applied on the whole file-collection, as soon as every file has been processed by the generator and put together
    • aliases: (array) an array, containing additional arrays. The sub-arrays' keys should be the file name that's being requested, while the values should be the existing files within the file-system structure of the targetDir. For example, if there are three files named "fileOne.less", "fileTwo.less" and "fileThree.less" within the targetDir, an alias for those files could look like:

      'testalias' => array(
        'fileOne',
        'fileTwo',
        'fileThree'
      )

      By that, when a client requests the following url:

      http://syndetic.local/testalias.css

      ... it would receive all three files, processed and put together into one response.

Next, link the config file to config/main.conf.php.

Usage

Syndetic can be accessed through simple URLs. Here are some examples:

  • http://syndetic.local/common.js: Accesses the file common.js within js => targetDir
  • http://syndetic.local/jquery:common.js: Accesses the files jquery.js and common.js within js => targetDir
  • http://syndetic.local/jquery.js:nextlevel$common.js: Accesses the file jquery.js within js => targetDir and the file common.js within js => targetDir/nextlevel
  • http://syndetic.local/common.css: Accesses the file common.less within css => targetDir, if fileExtension is set to less and an Assetic LESS filter was set as generator
  • http://syndetic.local/myalias.css: Accesses the alias myalias within css => targetDir

Some last words

This piece of software is still in-development, experimental stuff. Use at your own risk and feel free to contribute and commit issues. Thanks! :-)

Something went wrong with that request. Please try again.