c33s/composer-yaml
Lightweight Composer plugin to enable YAML support in composer.json-style configuration and metadata. Useful for projects that prefer YAML over JSON, helping integrate YAML files into Composer workflows with minimal setup.
Installation:
composer require --dev c33s/composer-yaml
Ensure the package is listed in require-dev in your composer.json.
Basic Conversion: Run the conversion from the command line:
vendor/bin/composer-yaml convert composer.yml
This generates a composer.json file from your composer.yml.
First Use Case:
composer.yml (e.g., legacy systems or specific workflows).composer.json for compatibility with modern Composer tools, CI/CD pipelines, or Laravel’s ecosystem.Legacy Migration:
composer.yml to composer.json by converting files incrementally.composer.json before fully adopting it.CI/CD Integration:
# Example GitHub Actions step
- name: Convert composer.yml to composer.json
run: vendor/bin/composer-yaml convert composer.yml
Local Development:
post-install-cmd script in composer.json to auto-convert composer.yml on install:
{
"scripts": {
"post-install-cmd": [
"composer-yaml convert composer.yml"
]
}
}
composer.json already exists. Use conditionals or manual triggers instead.Laravel-Specific:
composer.json includes all required packages (e.g., laravel/framework, fruitcake/laravel-cors).composer dump-autoload
Custom Configurations:
--output or --merge to control the conversion process.File Overwrites:
composer.json files. Always back up or use --dry-run first:
vendor/bin/composer-yaml convert --dry-run composer.yml
Schema Limitations:
composer.yml may not support all composer.json features (e.g., complex scripts, plugins, or conditional logic). Test thoroughly after conversion.Dependency Conflicts:
composer.json might introduce version conflicts. Use composer validate to check:
composer validate composer.json
Laravel-Specific Issues:
optimize or config:cache commands may fail if the converted composer.json is malformed. Test in a staging environment first.Verbose Output:
Run with -v or --verbose for detailed conversion logs:
vendor/bin/composer-yaml convert -v composer.yml
Validation: Use Composer’s built-in validation:
composer validate composer.json
Custom Conversion Logic: If the package lacks specific features, extend it by:
jq or PHP).Integration with Laravel Mix/Vite:
Ensure the converted composer.json includes frontend dependencies (e.g., npm packages) if your project uses them. Example:
{
"extra": {
"laravel": {
"vite": ["resources/js/app.js"]
}
}
}
Document the Process:
Add a CONTRIBUTING.md or README section explaining the composer.yml to composer.json conversion workflow for teammates.
Version Pinning:
Pin the package version in composer.json to avoid unexpected behavior:
{
"require-dev": {
"c33s/composer-yaml": "^1.0"
}
}
How can I help you explore Laravel packages today?