17
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WordPressをComposerでインストールする

Last updated at Posted at 2014-03-14

WordPressのインストールをComposerでお手軽に(普通にやっても難しくないけどw)

まずcomposer.jsonを作る。(composer init だとうまく出来なかったので)

mkdir wp-install-dir && cd $_
vi composer.json

composer.jsonを以下の内容で保存してください。

{
    "name": "organization-name/project-name",
    "require": {
        "php": ">=5.3.0"
    },
    "extra": {
        "installer-paths": {
            "vendor/wordpress/wp-content/plugins/{$name}/": [
                "type:wordpress-plugin",
                "type:wordpress-muplugin"
            ]
        }
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://wpackagist.org"
        },
        {
            "type": "package",
            "package": {
                "name": "wordpress",
                "version": "4.9.8",
                "source": {
                    "type": "git",
                    "url": "https://github.com/WordPress/WordPress.git",
                    "reference": "4.9.8"
                }
            }
        }
    ]
}

後は、composer require wordpressを実行すればWordPressをダウンロードできます。

composer require wpackagist-plugin/akismetとすればakismetをダウンロードできます。
(wpackagistからダウンロードされます)

extra.installer-paths"vendor/wordpress/wp-content/plugins/{$name}/"はwordpressのpluginがinstallされるpathです。
WP_CONTENT_DIR定数でdirectoryを変更する際は、このpathも変更してください。

すごく簡単にやりたい人向け

atomita/wordpress-composer-templateを使ってください

wget https://raw.github.com/atomita/wordpress-composer-template/master/composer.json
wget https://raw.github.com/atomita/wordpress-composer-template/master/env-example -O .env
wget https://raw.github.com/atomita/wordpress-composer-template/master/index.php
composer run-script update-repositories-for-wordpress
composer require wordpress

これだけでcurrent directoryがpublic directory 兼 wp-content directoryとして動作する状態になります

17
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?