PHPackages                             assetflow/asset-flow - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. assetflow/asset-flow

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

assetflow/asset-flow
====================

A comprehensive CodeIgniter 4 library for managing UI framework assets with support for multiple adapters, caching, minification, and theming.

00HTML

Since Jan 3Pushed 4mo agoCompare

[ Source](https://github.com/kazashim/assetflow)[ Packagist](https://packagist.org/packages/assetflow/asset-flow)[ RSS](/packages/assetflow-asset-flow/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

AssetFlow - CodeIgniter 4 UI Asset Management Library
=====================================================

[](#assetflow---codeigniter-4-ui-asset-management-library)

AssetFlow is a comprehensive CodeIgniter 4 library for managing UI framework assets with support for multiple adapters, caching, minification, theming, and advanced production optimization features. It provides a clean, extensible architecture that allows developers to easily switch between different UI frameworks while maintaining consistent asset management practices across their applications. The library has evolved beyond basic asset management to become a complete front-end optimization solution, incorporating modern web performance techniques such as asset bundling, cache busting, image optimization, critical CSS extraction, and content security policy management.

This library was created to solve a common problem in CodeIgniter development: managing multiple UI frameworks and their associated assets across different projects. Instead of manually including CSS and JavaScript files for each framework, AssetFlow provides a unified interface that handles asset registration, CDN fallback, caching, and theming automatically. The adapter pattern makes it simple to switch between frameworks or add support for new ones without modifying the core library code. The advanced features introduced in recent updates extend this capability to production-ready deployments, enabling developers to achieve excellent Core Web Vitals scores and meet modern web performance standards.

AssetFlow supports eight UI framework adapters out of the box, including popular choices like Bootstrap 5 and Tailwind CSS, as well as creative adapters for special use cases like retro gaming interfaces, glassmorphism designs, and cyberpunk aesthetics. The new ComponentBridge adapter enables seamless integration of Vue.js and React components within CodeIgniter views, bridging the gap between server-side and client-side rendering paradigms. Each adapter implements a consistent interface, ensuring that switching between frameworks requires only a single configuration change rather than extensive code modifications.

AssetFlow was authored by Kazashim Kuzasuwat, a software developer passionate about creating clean, maintainable code solutions for common web development challenges. For questions, suggestions, or contributions, please contact the author at .

---

1. Installation
---------------

[](#1-installation)

### 1.1 Prerequisites

[](#11-prerequisites)

Before installing AssetFlow, ensure your development environment meets the following requirements. CodeIgniter 4.0 or higher is required, as the library leverages modern features of the framework including the configuration system, service containers, and cache handlers. PHP 8.0 or higher is recommended for optimal performance, though the library maintains compatibility with PHP 7.4 for projects that have not yet upgraded. For the advanced image optimization features, the GD extension or ImageMagick must be available on the server. For production deployments using asset bundling, ensure the project has write access to the public/assets directory for generated bundle files.

Your project should have Composer installed for dependency management, as AssetFlow follows modern PHP packaging practices. If you are working within an existing CodeIgniter 4 project, AssetFlow can be integrated seamlessly without requiring changes to your application's structure. For new projects, you may start with a fresh CodeIgniter 4 installation and add AssetFlow as described below. The library is designed to work alongside existing CodeIgniter asset management approaches, allowing gradual migration without disrupting current implementations.

The library includes optional dependencies for enhanced functionality. The matthiasmullie/minify package provides advanced JavaScript minification when the basic built-in minifier does not meet your requirements. For caching, AssetFlow supports multiple backends including Redis and Memcached when the corresponding PHP extensions are available. The file-based caching driver works without additional dependencies and is suitable for most use cases. The advanced features utilize additional optional dependencies that are automatically installed when using Composer to require the package with its suggested dependencies.

### 1.2 Installing via Composer

[](#12-installing-via-composer)

The recommended method for installing AssetFlow is through Composer, which handles autoloading and dependency management automatically. Open your terminal or command prompt, navigate to your CodeIgniter 4 project directory, and execute the following command to add AssetFlow to your project's dependencies. This command will download the latest stable version along with all required dependencies.

The AssetFlow library is available through Packagist under the assetflow/asset-flow package name. Add the package to your project using the Composer require command, which will automatically update your composer.json file and download all necessary files. Composer will also configure the autoloader to make AssetFlow classes available throughout your application.

```
composer require assetflow/asset-flow
```

If you want to include the optional dependencies for enhanced minification and image optimization capabilities, install the package with its suggested dependencies. This provides access to advanced features that may require additional external libraries for optimal performance.

```
composer require assetflow/asset-flow --with-dependencies
```

For projects that require the latest development version or need to test specific features not yet released, you can install directly from the GitHub repository by adding a VCS repository reference to your composer.json configuration.

```
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/kazashim/assetflow"
        }
    ],
    "require": {
        "assetflow/asset-flow": "dev-main as 1.0.0"
    }
}
```

After adding the repository configuration, run composer update to download and install the package along with its dependencies. Composer will automatically generate the autoloader configuration and make the AssetFlow classes available throughout your application. Run composer dump-autoload if you encounter any autoloading issues after installation.

### 1.3 Manual Installation

[](#13-manual-installation)

For projects that do not use Composer or for situations where you need to integrate AssetFlow without modifying your dependency configuration, manual installation is possible. Download the latest release from the GitHub repository releases page, then extract the archive to a temporary directory. Review the release notes to understand what features are included in that version and ensure compatibility with your project requirements.

Copy the app/Libraries/AssetFlow directory to your CodeIgniter application's app/Libraries/ directory. This directory contains all the core library files, adapter implementations, and driver classes needed for operation. If your application uses a different namespace for application classes, you may need to update the namespace declarations in the library files to match your configuration. Copy the app/Config/AssetFlow.php file to your application's app/Config/ directory, adjusting any configuration values as needed for your environment. The configuration file controls all runtime behavior including which adapter is used, caching settings, and advanced feature configurations.

For manual installation, you must ensure that the library files are properly autoloaded by CodeIgniter's autoloader. Add the following to your app/Config/Autoload.php file in the $classmap array if you encounter any autoloading issues. This maps the fully qualified class names to their file locations, ensuring PHP can locate and load the classes correctly.

```
$classmap = [
    'App\\Libraries\\AssetFlow\\AssetManager' => APPPATH . 'Libraries/AssetFlow/AssetManager.php',
    'App\\Libraries\\AssetFlow\\Drivers\\Minifier' => APPPATH . 'Libraries/AssetFlow/Drivers/Minifier.php',
    'App\\Libraries\\AssetFlow\\Drivers\\Cacher' => APPPATH . 'Libraries/AssetFlow/Drivers/Cacher.php',
    'App\\Libraries\\AssetFlow\\Drivers\\AssetBundler' => APPPATH . 'Libraries/AssetFlow/Drivers/AssetBundler.php',
    'App\\Libraries\\AssetFlow\\Drivers\\ImageOptimizer' => APPPATH . 'Libraries/AssetFlow/Drivers/ImageOptimizer.php',
    'App\\Libraries\\AssetFlow\\Drivers\\CriticalCssLoader' => APPPATH . 'Libraries/AssetFlow/Drivers/CriticalCssLoader.php',
    'App\\Libraries\\AssetFlow\\Drivers\\SecurityHeaders' => APPPATH . 'Libraries/AssetFlow/Drivers/SecurityHeaders.php',
    // Add adapter class mappings as needed
];
```

### 1.4 Directory Structure

[](#14-directory-structure)

After successful installation, your project structure should include the AssetFlow library files in the expected locations. The library is organized into logical components that separate concerns and make the codebase maintainable. Understanding this structure will help you navigate the library files when customizing adapters, extending functionality, or troubleshooting issues. The advanced features introduced in recent versions add new driver classes to support asset bundling, image optimization, critical CSS extraction, and security header management.

The main library directory contains the AssetManager class, which serves as the primary entry point for all library operations. This class coordinates the adapter system, caching, minification, and asset rendering. The Interfaces directory contains the UiAdapterInterface that all adapters must implement, ensuring consistency across different framework integrations. The Adapters directory contains the concrete implementations for each supported UI framework, including both popular frameworks and creative adapters for specialized use cases.

The Drivers directory houses supporting functionality including the Minifier class for CSS and JavaScript compression, the Cacher class for managing cached asset output, and the new advanced feature drivers. The AssetBundler class manages the concatenation and optimization of multiple assets into efficient bundles. The ImageOptimizer class handles on-the-fly image conversion, resizing, and format optimization including WebP conversion. The CriticalCssLoader class extracts and inlines critical CSS for improved first contentful paint performance. The SecurityHeaders class generates and manages content security policy headers for enhanced application security.

```
your-project/
├── app/
│   ├── Config/
│   │   └── AssetFlow.php           # Library configuration
│   └── Libraries/
│       └── AssetFlow/
│           ├── AssetManager.php    # Main library class
│           ├── Interfaces/
│           │   └── UiAdapterInterface.php
│           ├── Drivers/
│           │   ├── Minifier.php
│           │   ├── Cacher.php
│           │   ├── AssetBundler.php     # Advanced: Asset bundling
│           │   ├── ImageOptimizer.php   # Advanced: Image optimization
│           │   ├── CriticalCssLoader.php # Advanced: Critical CSS
│           │   └── SecurityHeaders.php  # Advanced: CSP management
│           └── Adapters/
│               ├── Bootstrap5.php
│               ├── Tailwind.php
│               ├── Bulma.php
│               ├── Materialize.php
│               ├── RetroNES.php
│               ├── GlassUi.php
│               ├── CyberPunk.php
│               └── ComponentBridge.php  # Advanced: Vue/React integration
└── public/
    └── assets/
        └── vendor/                 # Local asset storage

```

---

2. Configuration
----------------

[](#2-configuration)

### 2.1 Basic Configuration

[](#21-basic-configuration)

The AssetFlow library is configured through the App\\Config\\AssetFlow configuration file, which provides sensible defaults while allowing customization for specific project requirements. After installation, copy the provided configuration file to your application's config directory if it was not automatically placed there during the installation process. The configuration file uses CodeIgniter's BaseConfig class, which provides validation and type casting for configuration values. You can modify the configuration by editing the property values directly or by setting configuration values in your controller or bootstrap files for environment-specific overrides.

The configuration file is organized into logical sections covering core settings, adapter configuration, caching behavior, and advanced feature options. The following example demonstrates a comprehensive configuration setup for a production environment that uses CDN resources with aggressive caching, asset bundling, and security features enabled. Review each configuration section to understand the available options and their effects on library behavior.

```
