Download the PHP package milbareu/wordpress-webpack-asset-manager without Composer

On this page you can find all versions of the php package milbareu/wordpress-webpack-asset-manager. 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 wordpress-webpack-asset-manager

WPAssets - WordPress Asset Manager

Introduction

WPAssets is a PHP class designed to manage assets in WordPress. It integrates with Webpack's manifest.json files, automatically enqueuing CSS, JS, and handling PHP dependencies ( with Dependency Extraction Webpack Plugin) in a structured and scalable way. This streamlines asset management in WordPress themes and plugins.

Features

Install via Composer

You can install WPAssets via Composer. Run the following command in your WordPress, theme or plugin directory:

1. Enqueueing Assets in WordPress

To enqueue a bundle (which includes CSS, JS, and optionally PHP files), use the WPAssets::enqueueBundle() function. This function pulls the required assets from the Webpack-generated manifest.json file.

2. Example Setup in functions.php

Here’s an example of how to use WPAssets in a WordPress theme to manage assets:

2.1 Example Webpack Configuration

The example/ folder contains sample Webpack configuration files that you can adapt for your project. These configurations support both production and development environments, allowing you to build optimized assets for each scenario.

2.2 Environment-Based Build

Make sure your Webpack configuration supports environment-based builds. For example, you can define separate configurations for development and production environments. These will generate different asset versions optimized for each use case.

In your Webpack configuration files (see the example/ folder):

3. Webpack Manifest Structure

Your Webpack configuration should output a manifest.json with an entrypoints object. Below is a sample structure for manifest.json:

4. Function Reference

enqueueBundle(string $entry, string $namespace = 'wpa') Enqueues the CSS, JS, and PHP files for a specified entry point.

Example:

getAsset(string $assetName, bool $getContents = false): ?string

Retrieves the URL or content of a single asset based on its name.

Example:

getAssetDependencies(string $entry): array

Retrieves the asset dependencies from the corresponding .asset.php file for a given entry.

Example:

5. Advanced Usage

To include specific PHP files from your Webpack configuration, ensure they are listed in the php key under the corresponding entry point in manifest.json. These files will be automatically included using include_once when the bundle is enqueued.

Example:

Contribution

Feel free to contribute by submitting issues or pull requests. Your contributions help improve this project and make it more useful for the community.

License

This project is licensed under the MIT License.

Disclaimer

This Webpack configuration has been tailored to meet my specific needs and preferences. While it does what I need for my projects, please note that I am not an expert in Webpack, and this setup may not be suitable for all projects or environments.

Feel free to use it, modify it, or adapt it to your own needs, but please do so at your own risk. I cannot guarantee that it will work perfectly for every situation, so always ensure you test it thoroughly in your own development and production environments.


All versions of wordpress-webpack-asset-manager with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
ext-json Version *
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 milbareu/wordpress-webpack-asset-manager contains the following files

Loading the files please wait ....