0
0

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 3 years have passed since last update.

ローカルでPHP+Composer環境を作ってちょっとテストしたいとき

Posted at

事前準備

  • Windows10
    • wsl2+Ubuntuをセットアップしておく
    • wsl2+Ubuntu上でPHPをインストールする
sudo apt update
sudo apt install php7.4
# 必要に応じて各モジュールもインストール(php7.4-zipやphp7.4-xmlなど)

手順

php composer.phar init
# いろいろ聞かれるが全部Enter or Noを選択
  • composerを使って試したいパッケージ等をインストール
# 例: MessagePackを試してみる
php composer.phar require rybakit/msgpack
  • dump-autoload実行
php composer.phar dump-autoload
  • 次のようなディレクトリ構成が作成される
+
|-- composer.json
|-- composer.lock
|-- composer.phar
|-- vendor
    |-- [requireしたpackage群]
  • 直下に作成したスクリプトの一番最初の列に下記を追加
<?php
require __DIR__ . '/vendor/autoload.php';
  • 実行
php test.php
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?