Skip to content

uxmz/PubSub-PHP

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PubSub for PHP Build Status

This is an implementation of PubSub for PHP that's designed to have a simple api.

Usage

<?php

include 'pub_sub.php';

// called when the admin area is loaded
PubSub::subscribe('/admin/load', function() {
  AdminArea::add_nav_link('Log out', '/logout');
});

// used to add js files to the page
PubSub::subscribe('/enqueue_js', function($additional_js = array()) {
  AssetManager::add_js(array_merge(array(
    'http://code.jquery.com/jquery.min.js',
    '/js/jquery.anything-slider.js'
  ), $additional_js));
});
?>

  <!-- product page -->
  <?php PubSub::publish('/enqueue_js', array('/js/product-gallery.js')); ?>
</body>
</html>

Packages

No packages published

Languages

  • PHP 100.0%