ForgePackageManager Module
Overview
ForgePackageManager is a powerful module management system for the Forge Framework that handles the installation, removal, and version control of modules. It supports both official and private module repositories, with built-in caching and version management capabilities.
Features
- Multiple Repository Support: Manage both official and private module repositories
- Version Control: Install specific versions of modules using @version syntax
- Caching System: Efficient caching of module manifests with configurable TTL
- Lock File Management: Automatic tracking of installed modules in forge.json and forge-lock.json
- Force Installation: Bypass cache when needed for fresh installations
Configuration
Configure ForgePackageManager through the module's configuration file:
// config/forge_package_manager.php
return [
'registry' => [
[
"name" => "private-modules",
"url" => "https://github.com/your-org/modules",
"branch" => "main",
],
],
'cache_ttl' => 3600 // Cache registry data for 1 hour
];
registry: Array of additional module repositories
cache_ttl: Time in seconds to cache repository manifests
Note: Modules prefixed with "forge-" are always fetched from the official registry, regardless of configuration.
CLI Commands
ForgePackageManager provides several CLI commands for module management:
# List all available modules
php forge.php package:list-modules
# Install all modules from forge-lock.json
php forge.php install:project
# Install a specific module
php forge.php install:module module-name[@version] [force]
# Remove an installed module
php forge.php remove:module module-name
package:list-modules: Display all available modules from configured repositories
install:project: Install all modules defined in forge-lock.json
install:module: Install a specific module, optionally with version and force flag
remove:module: Remove an installed module from the project
Usage
Example usage of ForgePackageManager commands:
# Install latest version of a module
php forge.php install:module forge-router
# Install specific version
php forge.php install:module forge-router@1.0.0
# Force install (bypass cache)
php forge.php install:module forge-router force
# Install specific version and force
php forge.php install:module forge-router@1.0.0 force
Important: When a module is installed, it's automatically added to your project's forge.json and forge-lock.json files. The lock file ensures consistent installations across different environments.