LoginSignup
0
1

More than 5 years have passed since last update.

WC REST API v2.0 を利用するためのサーバー設定

Last updated at Posted at 2018-02-27

WC REST APIを使うために必要な手順を説明します。
基本的にはSSHが使えるサーバーではないと無理かなと思います。
今回の例は多くの人が使えたらと思いますので、レンタルサーバーのXserverで設定した内容を書きます。
2018年2月27日現在

環境は以下となります。

  • WooCommerce 3.3.2
  • WordPress 4.9.4
  • WC-REST-API 2.0
  • composer 1.6.3

composerのインストール

WC-REST-API を利用するには composer をインストールする必要があります。
curl コマンドを使ってインストールする場合は、以下の php7.0 の部分を使っている PHP のバージョンに合わせる必要があります。
公式サイトではこちらのように説明されていますが、 brew でもインストールできそうなので、 Xserver などでなければ、そのような方法もあるかと思います。

composer_install
[artws@sv**** ***.com]$ curl -s https://getcomposer.org/installer | /usr/bin/php7.0
All settings correct for using Composer
Downloading...

Composer (version 1.6.3) successfully installed to: /home/artws/demo01web.info/composer.phar
Use it: php composer.phar
[artws@sv**** ***.com]$ 

composer の動作確認

composer と入力して動作するかを確認します。
以下のような画面が出てきたら大丈夫です。

composer
[artws@sv**** ***.com]$ composer
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.6.2 2018-01-05 15:28:41

Usage:
  command [options] [arguments]

Options:
  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi                     Force ANSI output
      --no-ansi                  Disable ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

WC-REST-API のインストール

A PHP wrapper for the WooCommerce REST API
上記に記載されている方法で、 WC-REST-API をインストールします。

wc_rest_api_install
[artws@sv**** ***.com]$ composer require automattic/woocommerce
Using version ^2.0 for automattic/woocommerce
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing automattic/woocommerce (2.0.0): Downloading (100%)         
Writing lock file
Generating autoload files
[artws@sv**** ***.com]$

これで、 WC-REST-API が利用できるようになります。

WC-REST-API の WordPress 側での設定や使い方は次の記事で。

0
1
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
0
1