PHP Classes

AssetInc: Add common JavaScript and CSS assets to a Web page

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 185 All time: 8,656 This week: 47Up
Version License PHP version Categories
assetinc 1.0.2MIT/X Consortium ...5.4HTML, PHP 5, Files and Folders, Traits
Description 

Author

This package can add common JavaScript and CSS assets to a Web page.

It can output HTML to load JavaScript libraries or CSS style sheets from common providers by a given name.

Currently it supports adding JavaScript and CSS files from Bootstrap and jQuery but it also supports adding assets from other vendors dynamically with a specific call or using traits.

Picture of Gavin Gordon Markowski
  Performance   Level  
Name: Gavin Gordon Markowski <contact>
Classes: 13 packages by
Country: Canada Canada
Age: 36
All time rank: 178541 in Canada Canada
Week rank: 41 Up1 in Canada Canada Up
Innovation award
Innovation award
Nominee: 5x

Documentation

AssetInc

Build Status

This class (GGG\AssetInc\AssetInc) provides a simple and quick way to include/add JS or CSS assets to an HTML document's head and/or body.

Installation

composer require gavinggordon/assetinc

Examples

Instantiation:

include_once( __DIR__ . '/vendor/autoload.php' );

$JSasset = \GGG\AssetInc\AssetInc::init( 'js' );

$CSSasset = \GGG\AssetInc\AssetInc::init( 'css' );

JS:

$JSasset->insert( 'jquery' );
// Result: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

$JSasset->add_asset( ASSET_NAME, ASSET_URL );
$JSasset->insert( ASSET_NAME );
// Result: ASSET_URL

CSS:

$CSSasset->insert( 'font-awesome' );
// Result: <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">

$CSSasset->add_asset( ASSET_NAME, ASSET_URL );
$CSSasset->insert( ASSET_NAME );
// Result: ASSET_URL

View this class package on PHPClasses.org.


  Files folder image Files (13)  
File Role Description
Files folder imagesrc (1 file, 1 directory)
Files folder imagetests (1 file)
Plain text file .scrutinizer.yml Data Auxiliary data
Plain text file .travis.yml Data travis.ci
Plain text file composer.json Data composer file
Plain text file phpunit.xml Data Auxiliary data
Plain text file README.md Doc. Description & Examples

  Files folder image Files (13)  /  src  
File Role Description
Files folder imageAssets (2 files, 3 directories)
  Plain text file AssetInc.php Class Class

  Files folder image Files (13)  /  src  /  Assets  
File Role Description
Files folder imageAbstracts (1 file)
Files folder imageInterfaces (1 file)
Files folder imageTraits (2 files)
  Plain text file Css.php Class Class
  Plain text file Js.php Class Class

  Files folder image Files (13)  /  src  /  Assets  /  Abstracts  
File Role Description
  Plain text file AbstractAsset.php Class Abstract

  Files folder image Files (13)  /  src  /  Assets  /  Interfaces  
File Role Description
  Plain text file AssetInterface.php Class Interface

  Files folder image Files (13)  /  src  /  Assets  /  Traits  
File Role Description
  Plain text file ScriptVendors.php Class Trait
  Plain text file StyleVendors.php Class Trait

  Files folder image Files (13)  /  tests  
File Role Description
  Plain text file AssetIncTest.php Test PHPUnit Test

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:185
This week:0
All time:8,656
This week:47Up