Download the PHP package silverbackis/common-js-bundle without Composer

On this page you can find all versions of the php package silverbackis/common-js-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 common-js-bundle

Common JS Bundle

Not affiliated with The CommonJS group

Build Status codecov

This bundle provides twig functions to easily add commonly used Javascript tags & SDKs to any page.

By default this bundle will support

Requirements

This bundle is only configured and tested to be used for Symfony >=3.4

All default configurations and examples assume you are using Symfony Flex.

Installation

This bundle will be submitted to the Symfony Flex contrib repository shortly with some example configs. If you're using flex, the bundle will automatically be added into yor bundles.php file though.

Enable the Symfony Flex Recipes Contrib Repository

Until merged set the SYMFONY_ENDPOINT env var:

Install the bundle:

Until merged, unset the environment variable:

Getting Started

Configuration

The default configuration values will work for 90% of use cases if you simply set the environment variables (when required). Other scripts will be enabled by default.

However, you may wish to create a config file to add in default blocks:

default_blocks can be an array of blocks you want. You can also include parameters if you want. It will pre-populate blocks in the order provided so you can just write {{ cjs_js('name') }} in your twig template

You cannot pass the default_blocks variable in via the twig template, but you can still remove and modify the default blocks from the template using cjs_add_block() and cjs_remove_block() functions

Identifiers will be added as environment variables by Flex into your .env file.

Set the IDs for these services if you want to enable them. Otherwise they will be disabled.

Example usage

Javascript blocks can be configured directly from your twig templates using the following functions

at_block_name can be "false" (note this is a string) which will result in the function returning the javascript for you to insert. You may which to track a click event for example when a user clicks a link instead of in the main tracking code.

You can duplicate an SDK block including any blocks that have already been configured

You can also remove a block (e.g. if you've duplicated a block but want to remove a specific section )

To generate a new model to be inserted as a parameter you can use cjs_model - this example shows how you can create your model with arguments to define variables and/or using setters and then how you would inject the model as a parameter into a block.

Finally to output the scripts after all the blocks have been configured for a given block use the cjs_js function

If there is an noscript fallback specified, you will want to output this at a different section in your template. This is implemented when using GTM for example. Yuu can output the fallback HTML using cjs_html

Models

There are models available for some SDK blocks (e.g. Google Analytics Event). You can use these to easily construct and pass data to a block. All models allow you to define all the variables in the constructor (in the order they are documented here) and also have getters and setters. Examples are provided in the individual script docs.

Supported Javascripts Docs

Google Analytics

Google Tag Manager (GTM)

Twitter

Facebook SDK

Contributing a new Javascript

Adding an SDK is pretty straight forwards.


All versions of common-js-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0.8 || ^7.1
symfony/framework-bundle Version ^3.4 || ^4
symfony/twig-bundle Version ^3.4 || ^4
symfony/serializer Version ^3.4 || ^4
symfony/property-access Version ^3.4 || ^4
symfony/validator Version ^3.4 || ^4
symfony/console Version ^3.4 || ^4
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 silverbackis/common-js-bundle contains the following files

Loading the files please wait ....