Composer
This docs shows you how to use Composer to install and update Meta Box and its extensions.
You can bundle Meta Box and free extensions in all products. For premium extensions:
- You can use them on websites for you or your clients.
- You cannot use them in free products, such as plugins and themes on WordPress.org.
- To use them in products and services that you sell to other people, contact us for a custom pricing plan.
For more information, see Bundling Meta Box.
Meta Box and free extensions
Meta Box and all free extensions are available on Packagist.
To use them in your project, simply run:
composer require wpmetabox/meta-box // For Meta Box
composer require wpmetabox/mb-rest-api // For MB Rest API
composer require wpmetabox/meta-box-lite // Or use Meta Box Lite, which includes Meta Box and all free extensions
Premium extensions
To use Composer to install paid extensions, add repositories rule to your composer.json:
"repositories":[
{
"type": "composer",
"url": "https://packages.metabox.io/YOUR_LICENSE_KEY"
}
],
Then you can install paid extensions with:
composer require meta-box/mb-settings-page:dev-master
composer require meta-box/meta-box-group:dev-master
Notes:
- The version of premium extensions specified in
composer.jsonmust bedev-master. We do not support version constraints for premium extensions yet. You always use the latest version. - Extensions are not autoloaded by default. You can manually load them or autoload by adding extensions' main files to the
autoloadarray incomposer.json. - Extensions then will be installed in WordPress's
wp-content/pluginsfolder thanks to composer/installers. To move them to the traditionalvendorfolder, addinstaller-pathsto yourcomposer.jsonfile as follows:
{
"repositories": [
{
"type": "composer",
"url": "https://packages.metabox.io/YOUR_LICENSE_KEY"
}
],
"require": {
"wpmetabox/mb-custom-post-type": "^2.3",
"meta-box/meta-box-group": "dev-master",
"meta-box/mb-settings-page": "dev-master"
},
"extra": {
"installer-paths": {
"vendor/meta-box/{$name}": [
"vendor:wpmetabox",
"vendor:meta-box"
]
},
},
"autoload": {
"files": [
"vendor/wpmetabox/mb-custom-post-type/mb-custom-post-type.php",
"vendor/meta-box/mb-settings-page/mb-settings-page.php",
"vendor/meta-box/meta-box-group/meta-box-group.php"
]
}
}
To make the extensions work, load Composer's autoload file:
require 'vendor/autoload.php';
Now you can start using Meta Box extensions in your products!
To make it easier for you, we have created a composer.json file, which contains a full list of extensions, free and premium. You can use it as a boilerplate and remove the extensions you do not want to use.
Because we use dev-master version, Composer cannot load versions to check when running composer update. To fix this, run the following command:
rm -rf vendor && composer clear-cache && composer install
This method disables the auto update mechanism and sometimes causes conflicts with the latest versions of WordPress, or with other plugins that use other versions of Meta Box and extensions. And you have to update extensions manually.