Composer命名规范咨询:WordPress插件多场景架构包命名方案
Great question! Let’s break this down into what’s technically allowed, what’s considered best practice, and the optimal approach for your scenario.
Can you use mmano/wordpress/plugin/plugin-name?
Technically, yes—Composer allows slashes in package names beyond the initial vendor/ segment (you’ll see examples like symfony/http-foundation or laravel/framework). However, this multi-level slash structure is generally reserved for large, established projects with a strict component hierarchy (like framework ecosystems). For a standalone plugin and its core library, it’s overkill and not the standard approach.
Is this a bad practice?
It’s not inherently "bad," but it’s definitely not ideal for your use case. Here’s why:
- Unnecessary verbosity: The long package name is harder to remember, type (when running
composer require), and reference in documentation. - Semantic confusion: Multi-level slashes can imply a tight coupling to a specific directory structure or namespace hierarchy, which isn’t required here. Your core package should be framework-agnostic, and the WP wrapper should clearly signal its purpose without burying it in nested categories.
- Community convention: Most Composer packages follow the
vendor/short-purposeful-namepattern. Devs familiar with the ecosystem will find a name likemmano/my-plugin-wpfar more intuitive than a deeply nested alternative.
What’s a better approach?
Stick to concise, descriptive names that clearly distinguish your core package from its WordPress wrapper:
- Core reusable package:
mmano/my-plugin-core(replacemy-pluginwith a name that reflects the core functionality—e.g.,mmano/form-engine-coreif it handles form logic). - WordPress plugin wrapper:
mmano/my-plugin-wp(ormmano/wp-my-plugin—either works, as long as it’s clear this is the WP-specific layer).
This structure:
- Makes dependencies obvious (the WP wrapper will explicitly require
mmano/my-plugin-corein itscomposer.json). - Aligns with community norms, making it easier for other devs to find and use your packages.
- Keeps your package names clean and maintainable as your project grows.
If you want to categorize your WP plugin for discoverability (e.g., on Packagist), add keywords like "wordpress-plugin" to the composer.json of the wrapper package instead of embedding categories in the name.
内容的提问来源于stack exchange,提问作者Michael Mano

