Download the PHP package tatter/assets without Composer

On this page you can find all versions of the php package tatter/assets. 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 assets

Tatter\Assets

Asset handling for CodeIgniter 4

Coverage Status

Quick Start

  1. Install with Composer: > composer require tatter/assets
  2. Enable the assets filter in app/Config/Filters.php
  3. Assign $routes to their assets in app/Config/Assets.php

Features

Provides automated asset loading for CSS and JavaScript files for CodeIgniter 4.

Installation

Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities and always be up-to-date:

Or, install manually by downloading the source files and adding the directory to app/Config/Autoload.php.

Configuration

The library's default behavior can be overridden or augmented by its config file. Copy examples/Assets.php to app/Config/Assets.php and follow the instructions in the comments. If no config file is found the library will use its default.

In order to use the AssetsFilter you must add apply it to your target routes. The filter does its own route matching so it is safe to apply it globally in app/Config/Filters.php. See Controller Filters for more info, or the Example section below.

Usage

If installed correctly CodeIgniter 4 will detect and autoload the library, config, and filter.

Asset

You may use the Asset class to build a tag for a single asset file:

... then in your view file:

The Asset class also comes with some named constructors to help you create the tag strings:

Named constructors make the above example much easier:

Bundle

Typically a project will need more than one single asset. The Bundle class allows you to collect multiple Assets into a single instance. Use the head() and body() methods to return the Assets destined for each tag, formatted as blocks of tags.

Bundles can be created one of two ways.

Class Properties

Create your own Bundle class and use these properties to stage the assets you want it to have:

Example:

define()

Bundle also comes with an initialization method: define(). Supply your own version of this method along with the fluent-style definition methods to create more complicated collections.

Example:

Filter

If you configured the AssetsFilter (see above) to load for your routes, you must also associate the specific assets or bundles per route. Use the config $routes property, where the route pattern is the key and the values are arrays of file paths, URLs, or bundle class names. E.g.:

If you apply the filter via your Routes config file you may also supply bundle class names as arguments to merge them with any other configured route bundles:

Example

You want to make a simple web app for browsing and uploading files, based on Bootstrap's frontend. Start your CodeIgniter 4 project, then add Bootstrap and DropzoneJS to handle the uploads:

composer require twbs/bootstrap enyo/dropzone

Note: You will need to copy files from vendor to public/assets/ to make them accessible, or use the framework's Publisher class to handle this for you.

Add this module as well:

composer require tatter/assets

Edit your Filters.php config file to enable the AssetsFilter on all routes:

Create a new Bundle to define your Bootstrap files in app/Bundles/DropzoneJS.php:

Then copy examples/Assets.php from this repo to app/Config/ and edit it so Bootstrap will load on every route and DropzoneJS will load on specific routes:

Note: We could have made a Bundle for Bootstrap as well but since they are only needed for one route this is just as easy.

If you finished all that then your assets should be injected into your <head> and <body> tags accordingly.

Your view file:

... served as:

Vendor Classes

This library includes two abstract class stubs to ease working with third-party assets. VendorPublisher is a wrapper for the framework's Publisher Library primed for use with Assets, and VendorBundle is a specialized version of this library's Bundle primed to handle assets published via VendorPublisher. Together these two classes can take a lot of the work out of managing assets you include from external sources.

Let's revisit the example above... Instead of copies the files into public/assets/ ourselves (and re-copying every time there is an update) let's create a VendorPublisher to do that for us. In app/Publishers/BootstrapPublisher.php:

That's all! VendorPublisher knows that $path is relative the to directory in your Assets config file, so when you run php spark publish next all the latest Bootstrap assets will be copied into that directory (default: public/assets/vendor/).

Note: Since these are external dependencies be sure to exclude them from your repo with your .gitignore file.

Now lets use these assets. We can create a new VendorBundle and use the new addPath() method to access the same files we just published from Composer's vendor directory. In app/Bundles/BootstrapBundle.php:

Now add the new bundle to our app/Config/Assets.php routes:

And we have hands-free Bootstrap updates from now on!

Testing

This library includes some PHPUnit extension classes in src/Test/ to assist with testing Assets and Bundles. These are used to test the files from this library but are also available for your own libraries and projects to use. Simply extend the appropriate test case and add a data provider method with your class name and criteria to meet. See the test files in tests/ for examples.


All versions of assets with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
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 tatter/assets contains the following files

Loading the files please wait ....