⚡ InstallWithAPCu Install dependencies with APCu autoloader cache enabled
🔍
InstallWithAPCuinstalls project dependencies with the--apcu-autoloaderoption, enabling APCu caching for the autoloader to improve class-loading performance, equivalent to runningcomposer install --apcu-autoloader.
📋 Signature
go
func (c *Composer) InstallWithAPCu() error📥 Parameters
| Parameter | Type | Description |
|---|---|---|
| None | — | This method takes no parameters |
📤 Return value
| Return value | Type | Description |
|---|---|---|
| First return value | error | Returned when an error occurs during installation; nil on success |
📝 Example
go
package main
import (
"log"
"github.com/scagogogo/composer-skills/pkg/composer"
)
func main() {
comp, err := composer.NewComposer()
if err != nil {
log.Fatalf("Failed to create Composer instance: %v", err)
}
if err := comp.InstallWithAPCu(); err != nil {
log.Fatalf("Failed to install dependencies: %v", err)
}
log.Println("Dependencies installed (APCu cache enabled)")
}🚀 Advanced
- ⚠️ Prerequisite: the APCu extension must be installed in the runtime environment, otherwise this option has no effect; you can confirm whether
apcuis present in thephp -moutput. - 🧪 It yields the most benefit in development environments where the application is frequently restarted; in production it is typically combined with
--optimize-autoloader— you can useInstallWithOptionsto pass bothapcuandoptimize-autoloaderat once. - 🔁 If you also need to skip development dependencies, use
Install(true, true)or combine multiple options viaInstallWithOptions. - 🔗 Under the hood it calls
c.Run("install", "--apcu-autoloader"); the working directory and Composer path are determined by theComposerinstance configuration.