Using Composer to manage WordPress plugins can streamline your development process and make it easier to manage dependencies. Composer is available on Ecenica Managed WordPress and cPanel shared hosting plans, allowing you to install and search for plugins directly from the terminal. This guide will walk you through the steps to install and search for WordPress plugins using Composer on your Ecenica Hosting account.
Prerequisites
- Composer Installed: Ensure that Composer is installed on your local machine or server.
- Access to Your Hosting Account: You need to have access to your Ecenica Hosting account and the relevant directory where WordPress is installed.
- Terminal Access: For cPanel users, ensure your hosting plan includes terminal access, typically available on Managed WordPress and cPanel shared hosting plans.
Step-by-Step Guide to Install Plugins
1. Access Your WordPress Directory
Log in to your Ecenica Hosting account via FTP or your preferred file manager and navigate to your WordPress installation directory (usually public_html).
2. Open Terminal in cPanel
If you need to create or edit the composer.json file, you can use the Terminal feature in cPanel:
- Log in to your cPanel account.
- Locate the Terminal icon under the “Advanced” section and click on it.
- This will open a terminal window where you can run commands.
3. Create or Edit composer.json
In the terminal, navigate to your WordPress installation directory:
cd public_html
To create or edit the composer.json file, you can use a text editor available in the terminal, such as nano:
nano composer.json
If the file doesn’t exist, this command will create it. Here’s a basic example of what your composer.json file might look like:
{
"name": "your-username/your-project",
"description": "Your WordPress project description",
"require": {
"php": ">=7.4",
"johnbillion/extended-cpts": "^2.2",
"wpackagist-plugin/wordpress-seo": "^1.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"allow-plugins": {
"johnpbloch/wordpress-core-installer": true
}
},
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
}
]
}
Press CTRL + O to save the file and CTRL + X to exit the editor.
4. Install the Desired Plugins
To install a plugin, you can use the following command in the terminal:
composer require wpackagist-plugin/plugin-name
Replace plugin-name with the actual name of the plugin you wish to install. This command will automatically add the plugin to your composer.json file and install it.
For example, to install the WordPress SEO plugin, you would run:
composer require wpackagist-plugin/wordpress-seo
After running the command, Composer will update your composer.json file and download the specified plugin.
If you have just created the composer.json file and have not yet run the composer install command, you can edit the composer.json file directly to add the plugins you want. Here’s how you can do it:
To install a plugin, specify it in the require section of your composer.json. For example:
"wpackagist-plugin/plugin-name": "version"
For plugins hosted on Packagist or other repositories, use:
"vendor/package-name": "version"
5. Run Composer Install
After setting up your composer.json, run the following command in your terminal:
composer install
This command will download and install all the dependencies specified in your composer.json, including the WordPress plugins.
6. Activate Plugins in WordPress
After installing the plugins, go to your WordPress admin panel:
- Navigate to Plugins > Installed Plugins.
- Find the newly installed plugins in the list and click Activate.
7. Keep Your Plugins Updated
To update your plugins managed by Composer, run:
composer update
This command will check for the latest versions of the plugins specified in your composer.json and update them accordingly.
7. Searching for WordPress Plugins in the Terminal
You can also search for WordPress plugins directly from the terminal using Composer or WP-CLI.
Searching for Plugins Using Composer
To search for plugins available on WPackagist, you can use:
composer search packagist-plugin
For specific plugins, run:
composer search [plugin-name]
Replace [plugin-name] with the name of the plugin you are looking for.
Searching for Plugins Using WP-CLI
If you have WP-CLI installed, you can search for plugins using the following command:
wp plugin search [plugin-name]
Replace [plugin-name] with the name or keywords related to the plugin you want to find.
Example Usage
To search for a plugin called “SEO”:
composer search wpackagist-plugin/seo
or
wp plugin search seo
Example output:
+-----------------------------------------------------------------------------------+---------------------+--------+ | name | slug | rating | +-----------------------------------------------------------------------------------+---------------------+--------+ | Yoast SEO | wordpress-seo | 96 | | All in One SEO – Powerful SEO Plugin to Boost SEO Rankings & Increase Traffic | all-in-one-seo-pack | 94 | | Rank Math SEO – AI SEO Tools to Dominate SEO Rankings | seo-by-rank-math | 98 | | SEOPress – On-site SEO | wp-seopress | 96 | | The SEO Framework – Fast, Automated, Effortless. | autodescription | 98 | | Slim SEO – Fast & Automated WordPress SEO Plugin | slim-seo | 94 | | LiteSpeed Cache | litespeed-cache | 96 | | Translate WordPress with GTranslate | gtranslate | 98 | | SEO Plugin by Squirrly SEO | squirrly-seo | 94 | | WooCommerce | woocommerce | 90 | +-----------------------------------------------------------------------------------+---------------------+--------+
Troubleshooting
• Composer Not Found: Ensure that Composer is correctly installed on your server or local machine.
• Permission Issues: If you encounter permission errors, make sure that the directory where you are installing the plugins has the correct permissions set.
Using Composer to manage and search for WordPress plugins simplifies the installation and update process. By following the steps above, you can easily add and manage plugins for your WordPress site hosted on Ecenica. If you have any questions or encounter issues, feel free to reach out to our support team.