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

Composer Configurable Plugin Laravel Package

cweagans/composer-configurable-plugin

Composer plugin that makes package configuration flexible by reading and merging settings from composer.json (extra) and other sources. Useful for teams needing configurable behavior across environments without hardcoding values in the plugin itself.

Deep Wiki
Context7

Getting Started

Start by installing the package via Composer: composer require cweagans/composer-configurable-plugin. Once installed, register the plugin in your composer.json by adding it to the extra.plugins section under the type key composer-configurable-plugin. The plugin looks for configuration in a composer.configurable.php file at the project root (or defined via the configurable-config extra key). Your first use case will likely involve defining a configuration schema that other Composer plugins or custom scripts can consume—e.g., enabling plugin-specific settings like cache paths, API endpoints, or feature flags without hard-coding them.

Implementation Patterns

Use composer.configurable.php to define a configuration schema as an associative array with keys for required, optional, and defaults. Return this schema from the file, and it will be merged with environment variables, config overrides (config section in composer.json), and runtime arguments. Plugins or scripts can then read the resolved configuration via Composer\Config::getConfigSource()->getAllConfig() (look for the extra.configurable namespace). Common patterns include defining environment-specific settings (e.g., LOCAL_CACHE_DIRconfig.local.php) or exposing plugin behavior toggles (e.g., enable_cdn, strict_validation) without modifying source code. Leverage the Composer\EventDispatcher\Event objects to inject configuration values into custom script logic.

Gotchas and Tips

Configuration values are not auto-cast—ensure explicit validation and type coercion in your consumer code (e.g., cast true/false strings to booleans using filter_var($value, FILTER_VALIDATE_BOOLEAN)). The package doesn’t validate schema at install time—misconfigured values may only surface as runtime errors. If your plugin depends on this config system, document the expected keys and types clearly. Use the configurable-config extra key to override the default config file path for monorepos. Debug config resolution by running composer show -p and inspecting the extra section, or add a pre-update script to var_dump(Composer\Factory::getComposer()->getConfig()->getAllConfig()) to trace effective values. Note: This package itself doesn’t provide any CLI; it’s purely a configuration infrastructure layer—consumers must implement the actual plugin behavior.

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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport