Install WordPress and plugins with Composer

Installing WordPress via Composer has often been difficult, fortunately there is now a solution!

WordPress

On Github there is a project that is currently updated every 15 minutes with the latest version of WordPress. It is also the most used. https://github.com/johnpbloch/wordpress

In the dial. In this example, we can also indicate which wordpress folder will be installed.

{
  "require":
    "php": "5.4"
    "johnpbloch/wordpress": "4.2"
  },
  "extra":
    "wordpress-install-dir": "wp"
  }
}

Then just use the installation command to dial

composer install

In our folder "wp" is now wordpress. Now when other plugins want to be installed, by default these end up in the folder /vendor. To install the plugins directly in the desired folder, we will have to get help by composing-install.

This allows you to use the types of packets and install them in the right place.

Composer Install

composer-installs lets a package specify its type and a custom install rental. They have a few types already included that we care about:

  • wordpress-plugin – wp-content/plugins/$name
  • wordpress-theme – wp-content/themes/$name
  • wordpress-muplugin – wp-content/mu-plugins/$name

So any package with the "wordpress-plugin" type will automatically install in "wp-content/plugins/$name" by defect.

WordPress Packagist

Outlandish has created a receiver containing all WordPress plugins in dial mode, this is found under WordPress Packagist.

Just add the desired package and install the desired plugin.

{
"repositories": [
    {
      "type": "compose"
      "url": "http://wpackagist.org"
    }
  ],
  "require":
    "php": "5.4"
    "johnpbloch/wordpress": "4.2"
    "wpackagist-plugin/advanced-custom-fields": "O"
  },
  "extra":
    "wordpress-install-dir": "cms"
  }
}

except that…

The Plugins

Publicités

The problem is that previously WordPress was installed in the cms folder. So we're going to have to rewrite that, to do it, we add an "extra" with the desired solution

{
"repositories": [
    {
      "type": "compose"
      "url": "http://wpackagist.org"
    }
  ],
  "require":
    "php": "5.4"
    "johnpbloch/wordpress": "4.2"
    "wpackagist-plugin/advanced-custom-fields": "O"
  },
  "extra":
    "wordpress-install-dir": "cms"
    "install-paths":
      "cms/wp-content/plugins/$name":["type:wordpress-plugin"]
    }
  }
}

So you'll end up with the plugins installed in the right place and can activate them as you wish in the adminsitration console

Publicités

Leave a Reply