GithubHelp home page GithubHelp logo

nanjingboy / assetloader Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 300 KB

A simple library to load javascript & css files for PHP

Home Page: https://packagist.org/packages/nanjingboy/assetloader

PHP 98.93% CoffeeScript 0.01% CSS 0.62% JavaScript 0.45%

assetloader's Introduction

AssetLoader:

AssetLoader is a simple library to load javascript & css files.

Getting Started:

  • Create composer.json file in root directory of your application:
 {
    "require": {
        "php": ">=5.4.0",
        "nanjingboy/assetloader": "*"
    }
}
  • Install it via composer

  • Create directory in root directory of your application:

 $ mkdir tmp/assetLoader -p
 $ chmod -R a+w tmp
  • Init the config in your bootstrap.php:
<?php
require __DIR__ . '/vendor/autoload.php';
AssetLoader::init($serverRootPath, $jsDirectoryPath, $cssDirectoryPath);

Usage:

We can use the require or require_dir directive to load the dependencies, there are the formats for this directive below:

  • CoffeeScript:
# require dependency
# require_dir dependency_dir
  • JavaScript, Scss, Less:
// require dependency
// require_dir dependency_dir
  • JavaScript, Css, Scss, Less(single line):
/* require dependency */
/* require_dir dependency_dir */
  • JavaScript, Css, Scss, Less(multi line):
/**
 * require one_dependency
 * require two_dependency
 * require_dir dependency_dir
 */

Notes:

  • The require comments must on the top in a asset file.
  • The dependency's path is relative with the root directory path of your javascripts or stylesheets.
  • The require_dir directive auto load all files in this directory without recursive.
  • It's just used to parse the load paths for asset's dependencies, it can't compile any files(e.g. a coffeeScript file).

Example:

Get a example from test

License:

MIT

assetloader's People

Contributors

nanjingboy avatar

Watchers

 avatar

Forkers

g7sim

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.