0
1

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 1 year has passed since last update.

composerのインストールとautoload対応

Last updated at Posted at 2023-02-07

composerのインストール

composer.jsonを自動生成

composer init

ファイルが生成される

composer.json
{
    "name": "フォルダ名",
    "autoload": {
        "psr-4": {
            "フォルダ名": "src/"
        }
    },
    "authors": [
        {
            "name": "名前",
            "email": "メールアドレス"
        }
    ],
    "require": {}
}

もしcomposer initで下記のようなエラーが出力されたら
image.png

php.iniを編集

extension_dir = "ext"
extension=openssl

下記コマンドを実行

composer config -g -- disable-tls true
composer init

aoutload対応

composer.jsonを書き換える
"app/"は実行するファイル

composer.json
{
    "autoload": {
        "psr-4": {
            "App\\" : "app/"
        }
    }
}

ファイルの書き換えが完了したら

composer install

vendorフォルダ、composer.lockが生成される。
image.png

もしファイルの内容を書き換えた場合は

composer update

または

composer dump-autoload
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?