2017 © Pedro Peláez
 

library webloader

Simple, easy to use, php bundler for javascript and css

image

machy8/webloader

Simple, easy to use, php bundler for javascript and css

  • Monday, April 30, 2018
  • by Machy8
  • Repository
  • 2 Watchers
  • 3 Stars
  • 3,242 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 10 Versions
  • 24 % Grown

The README.md


📦 Simple, easy to use, php bundler for javascript and css., (*1)

In a nutshell

  • Configurable: in one file (example bellow or in docs)
  • Files collections and containers: makes assets organizing incredibly simple
  • Filters: callable in two different ways
  • Path placeholders: reusable paths to files, less writing
  • Allows you to load remote and local files
  • If you have some critical css, you can load it directly into the page with minimal configuration required
  • Prepared for read only deployment - webloader is able to compile all files collections at once
  • Debugger bar for Tracy

Requirements

  • PHP 8.0+
  • If you use Nette Framework - v2.4+

Installation

 composer require machy8/webloader

Docs

Quick start

Let's say we have two css files (styla-a.css and style-b.css) and we want to bundle them into one file which name will be my-bundle. This bundle will be stored in a webtemp dir (must be accessible from a browser)., (*2)

The recommended way to configure Web Loader is through neon configuration files. The first step is to create a bundle.neon., (*3)

my-bundle:
    cssFiles:
        - path/to/style-a.css
        - path/to/style-b.css

Next step is to init Web Loader, set the output dir path and tell him to create bundles from bundle.neon., (*4)

$webloader = new \WebLoader\Engine('path/to/webtemp');
$webloader->createFilesCollectionsFromConfig('path/to/bundle.neon');

The last step is to call files collections render to render css files collection named my-bundle., (*5)

echo $webloader->getFilesCollectionRender()->css('my-bundle');

The PHP file after the last edit will looks like this:, (*6)

$webloader = new \WebLoader\Engine('path/to/output/dir');
$webloader->createFilesCollectionsFromConfig('path/to/bundle.neon');

echo $webloader->getFilesCollectionRender()->css('my-bundle');

The output will be similiar to the following code:, (*7)

<link type="text/css" rel="stylesheet" href="/path/to/webtemp/my-bundle.css?v=1512829634">

Quick start (for Nette Framework)

For the Nette Framework it is very similar. First of all, register Web Loader extension., (*8)

extensions:
    webloader: WebLoader\Bridges\Nette\WebLoaderExtension

Next step is to add Web Loader section with my-bundle collection configuration inside., (*9)

webloader:
    filesCollections:
        my-bundle:
            cssFiles:
                - path/to/style-a.css
                - path/to/style-b.css

In your presenter, inject the engine..., (*10)

/**
 * @var Engine
 */
private $webLoader;


public function __construct(\WebLoader\Engine $engine)
{
    $this->webLoader = $engine;
}

and set template parameters (for example in the beforeRender method)., (*11)

public function beforeRender()
{
    $this->template->webloaderFilesCollectionRender = $this->webLoader->getFilesCollectionRender();
}

The last step is to call the render in a latte template., (*12)

{$webloaderFilesCollectionRender->css('my-bundle')|noescape}

The Versions

30/04 2018

dev-master

9999999-dev

Simple, easy to use, php bundler for javascript and css

  Sources   Download

BSD-3-Clause New BSD License

The Requires

 

The Development Requires

css frontend javascript webloader module-bundler build-tool

12/04 2018

v1.2.0

1.2.0.0

Simple, easy to use, php bundler for javascript and css

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

css frontend javascript webloader module-bundler build-tool

12/03 2018

1.1.x-dev

1.1.9999999.9999999-dev

Simple, easy to use, php bundler for javascript and css

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

css frontend javascript webloader module-bundler build-tool

12/03 2018

v1.1.2

1.1.2.0

Simple, easy to use, php bundler for javascript and css

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

css frontend javascript webloader module-bundler build-tool

07/03 2018

v1.1.1

1.1.1.0

Simple, easy to use, php bundler for javascript and css

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

css frontend javascript webloader module-bundler build-tool

18/12 2017

v1.1.0

1.1.0.0

Simple, easy to use, php bundler for javascript and css

  Sources   Download

New BSD License

The Requires

 

The Development Requires

css frontend javascript webloader module-bundler build-tool

02/12 2017

1.0.x-dev

1.0.9999999.9999999-dev

Simple, easy to use, php bundler for javascript and css

  Sources   Download

New BSD License

The Requires

 

The Development Requires

css frontend javascript webloader module-bundler build-tool

02/11 2017

v1.0.2

1.0.2.0

Simple, easy to use, php bundler for javascript and css

  Sources   Download

New BSD License

The Requires

 

The Development Requires

css frontend javascript webloader module-bundler build-tool

26/10 2017

v1.0.1

1.0.1.0

Simple, easy to use, php bundler for javascript and css

  Sources   Download

New BSD License

The Requires

 

The Development Requires

css frontend javascript webloader module-bundler build-tool

24/10 2017

v1.0.0

1.0.0.0

Simple, easy to use, php bundler for javascript and css

  Sources   Download

New BSD License

The Requires

 

The Development Requires

css frontend javascript webloader module-bundler build-tool