Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Using Composer to manage your WordPress themes and plugins

Composer

Composer is a dependency manager for PHP projects, allowing you to automatically manage your project’s dependencies and packages via the command line. There are tonnes of packages out there that you can include in your projects using Composer, making it a breeze.

Composer, therefore, is great for your everyday PHP projects – but you can also use it to manage your Wordpress plugins and themes, too!

Packagist is the main Composer repository which will be used by default when you’re including packages in your projects, however the excellent WordPress Packagist from Outlandish acts as a repository for the WordPress theme and plugin SVNs.

Using Composer with WordPress

Let’s start with a fresh WordPress installation. Grab your copy from wordpress.org and set it up. Then, in the root of your WP installation, create the following `composer.json` file:

{
    "name": "mobius/wordpress-site",
    "description": "A superpowered WordPress site",
    "repositories":[
        {
            "type":"composer",
            "url":"http://wpackagist.org"
        }
    ],
    "require": {
        "wpackagist-plugin/mobius-conversion-tracker":"1.*"
    },
    "autoload": {
       "psr-0": {
           "Acme": "src/"
       }
    }
}

You can change your `composer.json` file if you need to, but the important part is the `repositories` object which will make sure we use WP Packagist.

Next, let’s grab a copy of Composer so we can use it. Run `curl -sS http://getcomposer.org/installer | php` and once it’s downloaded, simply run `php composer.phar install` to install your specified plugins or themes. In this example, we’ll be downloading the Mobius Conversion Tracker plugin.

That’s it! If you check out your `wp-content/plugins` folder, you should now see our conversion tracker plugin has been downloaded and installed to WordPress.

Now you can easily make sure your dependencies are up to date by running `php composer.phar update`. Composer will scan for changes, and download the latest version if there is one.

The post Using Composer to manage your WordPress themes and plugins appeared first on Mobius Media.



This post first appeared on Latest News - Mobius Media, please read the originial post: here

Share the post

Using Composer to manage your WordPress themes and plugins

×

Subscribe to Latest News - Mobius Media

Get updates delivered right to your inbox!

Thank you for your subscription

×