- What is hostnet/path-composer-plugin-lib?
- It is a small Hostnet library for building Composer path plugins that customize where packages are installed. It provides reusable plugin infrastructure and publishes Composer's vendor_dir and base_dir values as constants. It is aimed at PHP projects, including Laravel applications, that need project-specific package routing.
- How do I install hostnet/path-composer-plugin-lib?
- Install it with Composer using composer require hostnet/path-composer-plugin-lib. If you only need it while developing your own Composer path plugin, consider installing it as a dev dependency. Check the package's composer.json for the PHP and Composer version constraints before adding it.
- Does hostnet/path-composer-plugin-lib work with Laravel?
- Yes, it can be used in Laravel projects because it operates at the Composer level rather than depending on Laravel framework APIs. It is not a typical Laravel package with service providers or config files. Laravel version compatibility depends on your project's PHP and Composer constraints.
- How does this library help customize where Composer packages are installed?
- It gives you reusable infrastructure for writing a Composer path plugin, so your plugin can decide which package types should be installed into which project directories. This helps keep vendor code and custom code organized. Your plugin still defines the actual package-type mappings.
- What are the vendor_dir and base_dir constants used for?
- The library publishes Composer's vendor_dir and base_dir values as constants so plugin code can reference those paths without recalculating them. This is useful when install paths need to be resolved relative to the project root or vendor directory. Check the README or source for the exact constant names exposed by the package.
- Do I need to configure anything in composer.json to use it?
- You need Composer to load the plugin that you build with this library, so your plugin package must be required and allowed where applicable. On Composer 2.2 and later, custom plugins may require an allow-plugins entry in composer.json. The library itself is primarily infrastructure for your plugin rather than a standalone installer.
- Can I use it to route specific Composer package types to custom directories?
- Yes, that is the intended use case for building a Composer path plugin. You implement the logic that maps package types to directories, while this library supplies reusable plugin and path-constant infrastructure. It does not ship a ready-made directory mapping for every package type.
- Is hostnet/path-composer-plugin-lib safe to use in production?
- Composer plugins run during dependency installation, so treat them like build tooling and review the plugin code you build or install. Pin versions, test in CI, and use Composer's allow-plugins configuration to control which plugins may run. The library is small infrastructure, so production safety depends heavily on the path plugin that uses it.
- How do I test a Composer path plugin built with this library?
- Create a throwaway Composer project with a path repository or fixture package, then run composer install or composer update to verify the install locations. Assert that the published vendor_dir and base_dir constants resolve correctly in your plugin code. Add these checks to CI so path-routing changes are caught before release.
- What are alternatives to hostnet/path-composer-plugin-lib?
- Common alternatives include composer/installers, oomphinc/composer-installers-extender, or writing a custom Composer plugin directly. This library is most useful when you want reusable path-plugin infrastructure and vendor_dir/base_dir constants. Review its GitHub repository and tagged releases before adopting it for long-term maintenance.