Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laminas Component Installer Laravel Package

laminas/laminas-component-installer

Composer plugin for Laminas and Mezzio apps that automates discovery, installation, and configuration of components/modules. Updates application config during composer install/update to enable packages with minimal manual setup.

View on GitHub
Deep Wiki
Context7

Getting Started

This package, Laminas Component Installer, is a lightweight utility for managing component installation and autoloading in PHP/Laravel projects. While not Laravel-specific, it integrates seamlessly with Composer-based workflows (Laravel's default).

First steps:

  1. Install via Composer:
    composer require laminas/laminas-component-installer
    
  2. Use it to install components programmatically (e.g., in a custom installer script or Laravel service provider).
  3. Leverage it for PHP 8.5 projects (newly supported) or migrate from PHP 8.1 (now unsupported).

First use case: Automate component installation in a Laravel package or custom deployment script:

use Laminas\ComponentInstaller\Installer\Installer;

$installer = new Installer();
$installer->install('vendor/package', 'path/to/install');

Implementation Patterns

Laravel Integration

  1. Service Providers: Use the installer in a Laravel ServiceProvider to set up dependencies during boot:

    public function boot()
    {
        $installer = new Installer();
        if (!$installer->isInstalled('vendor/required-package')) {
            $installer->install('vendor/required-package', storage_path('app/dependencies'));
        }
    }
    
  2. Artisan Commands: Create a custom Artisan command for CLI-driven installation:

    use Laminas\ComponentInstaller\Installer\Installer;
    
    class InstallDependenciesCommand extends Command
    {
        protected function handle()
        {
            $installer = new Installer();
            $installer->install('vendor/package', 'custom/path');
            $this->info('Dependencies installed!');
        }
    }
    
  3. Package Development: Bundle the installer in your Laravel package’s composer.json as a dev dependency to automate setup for end users.

Workflows

  • Post-Install Hooks: Trigger installations after composer install via a post-install-cmd script in composer.json:

    {
        "scripts": {
            "post-install-cmd": [
                "Laminas\\ComponentInstaller\\Installer\\Installer::install('vendor/package', 'path')"
            ]
        }
    }
    

    (Note: Requires custom scripting; use a Laravel event listener for tighter integration.)

  • Configuration-Driven: Store installation paths/configs in config/installer.php and load them dynamically:

    $config = config('installer.components');
    foreach ($config as $component) {
        $installer->install($component['vendor'], $component['path']);
    }
    

Gotchas and Tips

Breaking Changes (PHP 8.1 Dropped)

  • Action Required: If your project uses PHP 8.1, update to PHP 8.2+ (8.5 now supported). Test thoroughly—some edge cases (e.g., legacy autoloading) may break.

    • Debugging: Use php -v to check your PHP version. Enable strict_types=1 in composer.json to catch type-related issues early.
  • Laravel Compatibility: Ensure your Laravel version supports PHP 8.5 (Laravel 10+ does). Check Laravel’s PHP requirements.

Performance and Quirks

  1. Autoloading Conflicts:

    • The installer doesn’t manage Composer autoloading. Use composer dump-autoload after installations.
    • Tip: Combine with laravel-mix or vite for frontend dependencies to avoid duplication.
  2. Permissions:

    • Installations may fail if the target directory lacks write permissions. Use:
      $installer->setPermissions(0755); // Set during instantiation
      
    • For Laravel, ensure storage/ and bootstrap/cache/ are writable (standard Laravel setup).
  3. Extension Points:

    • Custom Installers: Extend Laminas\ComponentInstaller\Installer\Installer to add pre/post-install logic:
      class CustomInstaller extends Installer
      {
          protected function onInstall($source, $target)
          {
              // Add logic here (e.g., symlink creation)
          }
      }
      
    • Event Listeners: Dispatch Laravel events (e.g., Installed) to integrate with queues/jobs:
      event(new Installed($source, $target));
      
  4. Debugging:

    • Enable verbose output:
      $installer = new Installer(['verbose' => true]);
      
    • Check logs in storage/logs/laravel.log for installation failures.
  5. PHP 8.5-Specific:

    • Test with named arguments (PHP 8.5’s new feature) if your installer methods use them.
    • Example: $installer->install(source: 'vendor/package', target: 'path').

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky