Download the PHP package idci/asset-loader-bundle without Composer

On this page you can find all versions of the php package idci/asset-loader-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package asset-loader-bundle

AssetLoaderBundle

Introduction

With the Symfony 2 (or 3) framework, we found it troublesome to load assets for custom form type widgets. A recurrent issue which comes up is the loading of front dependencies embedded to the widgets.

Issue 1 - dependencies order

Let's say you want to create a form type, child of the text form type, whose widget will color the background of the input type text; as soon as the input is empty. Your widget will look like this:

Form/fields.html.twig

As you can see, this javascript code requires jQuery. JQuery will not be available when this script will be executed (unless you place the Jquery script in the head of the html document, but we don't want that)

A possible solution would be to wrap this code with the following vanilla function

This way, when the code will be executed, Jquery should be ready to be used. But what if your widget is based on an entire library?

Issue 2 - dependencies duplication

Given the same form type as in the example above, if you have a page in your web application that render this form 3 times, you will end up with your scripts and stylesheets duplicated 3 times in the DOM. You only need it once.

This bundle attempts to solve those issues.

Installation

Add the dependency in your composer.json file:

Install these new dependencies in your application using composer:

Or with docker and docker-compose:

Register needed bundles in your application kernel:

If you want to activate the subscriber to load your assets automatically (more on that later, add the following in your config.yml file.

Usage

Asset declaration

Adding assets to your form type is pretty simple:

In the example below, we load assets from a form type. An AssetProvider does not necessarily have to be a form type, any service will do the job.

AbstractType

If you have multiple assets which must be loaded in a predicatble order, you can add a priority to the Asset (-1 by default). The higher the priority, the sooner it will be load in the DOM.

Services.yml

Loading your assets manually

You can use the idci_asset_loader.asset_dom_loader service to load the asset for one or all the providers. This will register a subscriber which will append the assets to the dom (at the end of the body) on kernel response.

Loading your assets automatically

In most case, you will just want to let the subscriber load all the assets for you. To load all the assets from all providers:

You can also load some specific providers. If load_all is set to true, the following will have no impact.

Tests

Run the tests:

Or with docker and docker-compose:


All versions of asset-loader-bundle with dependencies

PHP Build Version
Package Version
Requires twig/twig Version ~1.34|~2.4
php Version ^7.1.3
symfony/config Version ~4.2
symfony/dependency-injection Version ~4.2
symfony/event-dispatcher Version ~4.2
symfony/http-foundation Version ~4.2
symfony/http-kernel Version ~4.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package idci/asset-loader-bundle contains the following files

Loading the files please wait ....