Laravel をしらべる

作成日 : 2019-12-06
最終更新日 :

Laravel を WSL で試す

Laravel とは PHP のフレームワークである。以下、手習いの奮闘を記す。 以下は、WSL Ubuntu 18 のときの記録と WSL Ubuntu 20 のときの記録である。 WSL2 ではないので注意。

書籍


WSL Ubuntu 18 で失敗する

「PHP フレームワーク Laravel Web アプリケーション開発」 の通り準備を整えたつもりだったが失敗した。

$ vagrant box add laravel/homestead
    ==> box: Loading metadata for box 'laravel/homestead'
        box: URL: https://vagrantcloud.com/laravel/homestead
    This box can work with multiple providers! The providers that it
    can work with are listed below. Please review the list and choose
    the provider you will be working with.
    
    1) hyperv
    2) parallels
    3) virtualbox
    4) vmware_desktop
    
    Enter your choice: 3
    ==> box: Adding box 'laravel/homestead' (v9.1.0) for provider: virtualbox
        box: Downloading: https://vagrantcloud.com/laravel/boxes/homestead/versions/9.1.0/providers/virtualbox.box
        box: Download redirected to host: vagrantcloud-files-production.s3.amazonaws.com
        box:
        box: Calculating and comparing box checksum...
    ==> box: Successfully added box 'laravel/homestead' (v9.1.0) for 'virtualbox'!
    
$ vagrant up
  Check your Homestead.yaml (or Homestead.json) file, the path to your private key does not exist.    

最後の文は「Homestead.yaml を調べよ。秘密鍵がある場所が見つからない」という意味らしい。 Homestead.yaml の鍵部分を見てみる。

    authorize: ~/.ssh/id_rsa.pub
    keys:
    - ~/.ssh/id_rsa

一方、自分のホームディレクトリには .ssh フォルダがない。作ることにする。 https://k10i-tech.blogspot.com/2017/10/laravelhomestead.html 参照。

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\******/.ssh/id_rsa):
Created directory 'C:\Users\******/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\******/.ssh/id_rsa.
Your public key has been saved in C:\Users\******/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:****************************************** ******@*********
The key's randomart image is:
+---[RSA 2048]----+
| (snip)          |
+----[SHA256]-----+

再度コマンドを打つ。

$ vagrant up
Bringing machine 'homestead' up with 'virtualbox' provider...
==> homestead: Importing base box 'laravel/homestead'...
==> homestead: Matching MAC address for NAT networking...
==> homestead: Checking if box 'laravel/homestead' version '9.1.0' is up to date...
==> homestead: Setting the name of the VM: homestead
==> homestead: Clearing any previously set network interfaces...
==> homestead: Preparing network interfaces based on configuration...
    homestead: Adapter 1: nat
    homestead: Adapter 2: hostonly
==> homestead: Forwarding ports...
    homestead: 80 (guest) => 8000 (host) (adapter 1)
    homestead: 443 (guest) => 44300 (host) (adapter 1)
    homestead: 3306 (guest) => 33060 (host) (adapter 1)
    homestead: 4040 (guest) => 4040 (host) (adapter 1)
    homestead: 5432 (guest) => 54320 (host) (adapter 1)
    homestead: 8025 (guest) => 8025 (host) (adapter 1)
    homestead: 9600 (guest) => 9600 (host) (adapter 1)
    homestead: 27017 (guest) => 27017 (host) (adapter 1)
    homestead: 22 (guest) => 2222 (host) (adapter 1)
==> homestead: Running 'pre-boot' VM customizations...
==> homestead: Booting VM...
==> homestead: Waiting for machine to boot. This may take a few minutes...
    homestead: SSH address: 127.0.0.1:2222
    homestead: SSH username: vagrant
    homestead: SSH auth method: private key
    homestead: Warning: Connection aborted. Retrying...
    homestead:
    homestead: Vagrant insecure key detected. Vagrant will automatically replace
    homestead: this with a newly generated keypair for better security.
    homestead:
    homestead: Inserting generated public key within guest...
    homestead: Removing insecure key from the guest if it's present...
    homestead: Key inserted! Disconnecting and reconnecting using new SSH key...
==> homestead: Machine booted and ready!
==> homestead: Checking for guest additions in VM...
==> homestead: Setting hostname...
==> homestead: Configuring and enabling network interfaces...
==> homestead: Mounting shared folders...
    homestead: /vagrant => C:/Users/******/Homestead
    homestead: /home/vagrant/code => C:/Users/******/code
==> homestead: Running provisioner: file...
    homestead: c:/Users/******/Homestead/aliases => /tmp/bash_aliases
==> homestead: Running provisioner: shell...
    homestead: Running: inline script
==> homestead: Running provisioner: shell...
    homestead: Running: inline script
    homestead:
    homestead: ssh-rsa (snip) ******@******-PC
==> homestead: Running provisioner: shell...
    homestead: Running: inline script
==> homestead: Running provisioner: shell...
    homestead: Running: inline script
==> homestead: Running provisioner: shell...
    homestead: Running: inline script
==> homestead: Running provisioner: shell...
    homestead: Running: inline script
    homestead: Ignoring feature: mariadb because it is set to false
==> homestead: Running provisioner: shell...
    homestead: Running: inline script
    homestead: Ignoring feature: ohmyzsh because it is set to false
==> homestead: Running provisioner: shell...
    homestead: Running: inline script
    homestead: Ignoring feature: webdriver because it is set to false
==> homestead: Running provisioner: shell...
    homestead: Running: C:/Users/******/AppData/Local/Temp/vagrant-shellYYYYMMDD-nnnn-+++++++.sh
==> homestead: Running provisioner: shell...
    homestead: Running: C:/Users/******/AppData/Local/Temp/vagrant-shellYYYYMMDD-nnnn-+++++++.sh
==> homestead: Running provisioner: shell...
    homestead: Running: script: Creating Certificate: homestead.test
==> homestead: Running provisioner: shell...
    homestead: Running: script: Creating Site: homestead.test
==> homestead: Running provisioner: shell...
    homestead: Running: inline script
==> homestead: Running provisioner: shell...
    homestead: Running: C:/Users/******/AppData/Local/Temp/vagrant-shellYYYYMMDD-nnnn-++++++.sh
==> homestead: Running provisioner: shell...
    homestead: Running: script: Checking for old Schedule
==> homestead: Running provisioner: shell...
    homestead: Running: script: Clear Variables
==> homestead: Running provisioner: shell...
    homestead: Running: script: Restarting Cron
==> homestead: Running provisioner: shell...
    homestead: Running: script: Restarting Nginx
==> homestead: Running provisioner: shell...
    homestead: Running: script: Creating MySQL Database: homestead
==> homestead: Running provisioner: shell...
    homestead: Running: script: Creating Postgres Database: homestead
==> homestead: Running provisioner: shell...
    homestead: Running: script: Update Composer
    homestead: You are already using composer version 1.9.1 (stable channel).
==> homestead: Running provisioner: shell...
    homestead: Running: C:/Users/******/AppData/Local/Temp/vagrant-shellYYYYMMDD-nnnn-+++++++.sh
==> homestead: Running provisioner: shell...
    homestead: Running: script: Update motd
==> homestead: Running provisioner: shell...
    homestead: Running: C:/Users/******/AppData/Local/Temp/vagrant-shellYYYYMMDD-nnnn-+++++++.sh


これで成功した。 なお、上記の間2度、モーダルな画面で「Virtual Box に変更を加えるがよろしいか?」 という意味のウィンドウが出てくる。 Yes を選ぶ。また、上記の画面は適宜伏字にしている箇所もある。 ともあれ、無事 Vagrant の稼働成功を確認できた。

Welcome 画面

次は Welcome 画面である。 こちらは特に悩むこともなく、Laravel の Welcome 画面が出てきた。

Laradock

上掲書の p.17 には、Laradock を利用した環境構築の方法が述べられている。 しかし、私はこの節の内容を検証できない。なぜなら、手持ちのコンピュータは Windows 10 Home だからだ。 Windows で Docker を使うには Windows 10 の Professional か Enterprise かでないといけない。 なので、ここは諦める。 さいわい、p.24 以降の「最初のアプリケーション」では、Homestead での構築環境に戻っているから、 当面は大丈夫だ。

php artisan

1-3-4 はじめてのテストコードで、テストコードファイルを作成する例がある。しかし、 私はテストコードが作成できなかった。

$ php artisan make:test HomeTest
'php' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。

困った。さらに困ったことに、vagrant が立ち上がらない。

$ vagrant up
VBoxManage.exe: error: Could not rename the directory 'C:\Users\******\VirtualBox VMs\ubuntu-18.04-amd64_1575613440037_85513' \
to 'C:\Users\******\VirtualBox VMs\homestead' to save the settings file (VERR_ALREADY_EXISTS)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component SessionMachine, interface IMachine, callee IUnknown
VBoxManage.exe: error: Context: "SaveSettings()" at line 3206 of file VBoxManageModifyVM.cpp

調べてみると、vagrant destroy をするとよいと書いてあった。

$ vagrant destroy
    homestead: Are you sure you want to destroy the 'homestead' VM? [y/N] y
==> homestead: Destroying VM and associated drives...

もう一度試してみるが、現象は同じである。仕方がないので、$USERPROFILE\VirtualBox VMs にある関係しそうなフォルダをすべて削除した。その結果、正常に起動した。

さて、前に戻ろう。php というコマンドと叩いたら、なぜこういわれたのか。

'php' は、内部コマンドまたは外部コマンド、 操作可能なプログラムまたはバッチ ファイルとして認識されていません。

答は簡単で、 仮想環境にログインしていなかったからだ。$ vagrant ssh でログインする。

$ vagrant ssh
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-72-generic x86_64)
        
 Thanks for using
 _                               _                 _
| |                             | |               | |
| |__   ___  _ __ ___   ___  ___| |_ ___  __ _  __| |
| '_ \ / _ \| '_ ` _ \ / _ \/ __| __/ _ \/ _` |/ _` |
| | | | (_) | | | | | |  __/\__ \ ||  __/ (_| | (_| |
|_| |_|\___/|_| |_| |_|\___||___/\__\___|\__,_|\__,_|

* Homestead v10.0.0 released
* Settler v9.1.0 released
        
0 packages can be updated.
0 updates are security updates.

vagrant@homestead:~$

ここで力尽きた。


Laravel を WSL Ubuntu 20 で試す

Ubuntu 18 のときに力尽きてその後は全く Laravel のことを忘れていた。 今度は、WSL Ubuntu 20.04 で Laravel を試した。

Composer を入れる

Laravel には Composer というのが必要らしい。Composer とは、 A Dependency Manager for PHP、すなわち PHP の依存関係を管理するツールのようだ。 「Laravel リファレンス」という本にあるとおり、インストールした。

$ curl -sS https://getcomposer.org/install | php
(前略)
<title>An Error Occurred: Not Found</title>
(後略)

あれあれ、上記はリンク切れらしい。仕方がないので、 https://getcomposer.org に行って 4 行の PHP コマンドを試した通りに行なった。 これに付け加え、最後に、ダウンロードした composer.phar を次のようにして /usr/bin/composer としている。

$ sudo mv composer.phar /usr/bin/composer

なお、今回は HomeStead は使わなかった。ディスクがかなり逼迫していて、残り容量がわずかになるのを恐れたためだ。 ということで、素の Laravel をインストールする。

$ composer global require laravel/installer
Changed current directory to /home/username/.config/composer
Using version ^4.0 for laravel/installer
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 12 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-php80 (v1.18.1): Downloading (100%)
  - Installing symfony/process (v5.1.7): Downloading (100%)
  - Installing symfony/polyfill-mbstring (v1.18.1): Downloading (100%)
  - Installing symfony/polyfill-intl-normalizer (v1.18.1): Downloading (100%)
  - Installing symfony/polyfill-intl-grapheme (v1.18.1): Downloading (100%)
  - Installing symfony/polyfill-ctype (v1.18.1): Downloading (100%)
  - Installing symfony/string (v5.1.7): Downloading (100%)
  - Installing psr/container (1.0.0): Downloading (100%)
  - Installing symfony/service-contracts (v2.2.0): Downloading (100%)
  - Installing symfony/polyfill-php73 (v1.18.1): Downloading (100%)
  - Installing symfony/console (v5.1.7): Downloading (100%)
  - Installing laravel/installer (v4.0.5): Downloading (100%)
symfony/polyfill-mbstring suggests installing ext-mbstring (For best performance)
symfony/polyfill-intl-normalizer suggests installing ext-intl (For best performance)
symfony/polyfill-intl-grapheme suggests installing ext-intl (For best performance)
symfony/service-contracts suggests installing symfony/service-implementation
symfony/console suggests installing symfony/event-dispatcher
symfony/console suggests installing symfony/lock
symfony/console suggests installing psr/log (For using the console logger)
Writing lock file
Generating autoload files
10 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

これに呼応して、次のようにパスを追加する。.profile に書いておく。

PATH="$HOME/.config/composer/vendor/bin:$PATH"

このパスに、laravel コマンドが入っている。

新しいプロジェクトを作る

現在のディレクトリ配下に、blog という名前の Laravel のプロジェクトを作ることにした。 現在のディレクトリには、blog という名前のディレクトリはまだない。下記のコマンドで、 ディレクトリ blog が新しく作られると同時に環境が一式入るはずなのだが、成功するだろうか?

$ laravel new blog

    _                               _
   | |                             | |
   | |     __ _ _ __ __ ___   _____| |
   | |    / _` | '__/ _` \ \ / / _ \ |
   | |___| (_| | | | (_| |\ V /  __/ |
   |______\__,_|_|  \__,_| \_/ \___|_|
   
   Creating a "laravel/laravel" project at "./blog"
   Installing laravel/laravel (v8.2.0)
     - Installing laravel/laravel (v8.2.0): Downloading (100%)
   Created project in /mnt/c/Users/username/Documents/program/blog
   > @php -r "file_exists('.env') || copy('.env.example', '.env');"
   Loading composer repositories with package information
   Updating dependencies (including require-dev)
   Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/framework v8.9.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.8.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.7.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.7.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.6.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.5.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.4.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.3.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.2.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.11.2 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.11.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.11.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.10.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.1.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.0.4 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.0.3 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.0.2 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.0.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v8.0.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework 8.x-dev requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - Installation request for laravel/framework ^8.0 -> satisfiable by laravel/framework[8.x-dev, v8.0.0, v8.0.1, v8.0.2, 
      v8.0.3, v8.0.4, v8.1.0, v8.10.0, v8.11.0, v8.11.1, v8.11.2, v8.2.0, v8.3.0, v8.4.0, v8.5.0, v8.6.0, v8.7.0, v8.7.1, v8.8.0, v8.9.0].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/7.4/cli/php.ini
    - /etc/php/7.4/cli/conf.d/10-opcache.ini
    - /etc/php/7.4/cli/conf.d/10-pdo.ini
    - /etc/php/7.4/cli/conf.d/20-calendar.ini
    - /etc/php/7.4/cli/conf.d/20-ctype.ini
    - /etc/php/7.4/cli/conf.d/20-exif.ini
    - /etc/php/7.4/cli/conf.d/20-ffi.ini
    - /etc/php/7.4/cli/conf.d/20-fileinfo.ini
    - /etc/php/7.4/cli/conf.d/20-ftp.ini
    - /etc/php/7.4/cli/conf.d/20-gettext.ini
    - /etc/php/7.4/cli/conf.d/20-iconv.ini
    - /etc/php/7.4/cli/conf.d/20-json.ini
    - /etc/php/7.4/cli/conf.d/20-phar.ini
    - /etc/php/7.4/cli/conf.d/20-posix.ini
    - /etc/php/7.4/cli/conf.d/20-readline.ini
    - /etc/php/7.4/cli/conf.d/20-shmop.ini
    - /etc/php/7.4/cli/conf.d/20-sockets.ini
    - /etc/php/7.4/cli/conf.d/20-sysvmsg.ini
    - /etc/php/7.4/cli/conf.d/20-sysvsem.ini
    - /etc/php/7.4/cli/conf.d/20-sysvshm.ini
    - /etc/php/7.4/cli/conf.d/20-tokenizer.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

ext-mbstring がない、ということである。mbstring とはマルチバイトストリングのことだろう。

    $ sudo apt-cache search mbstring
    php-mbstring - MBSTRING module for PHP [default]
    php7.4-mbstring - MBSTRING module for PHP
    php-patchwork-utf8 - UTF-8 strings handling for PHP
    $

みんな入れてみよう。

    $ sudo apt install mbstring
    (中略)
    E: パッケージ mbstring が見つかりません

横着はするものではない。では、何を入れればいいのか。[default] とわざわざある php-mbstring でいいような気もするが、 前のコマンドの結果で /etc/php/7.4/ のディレクトリがこれ見よがしに出ているのも気になる。 迷った末、php7.4-mbstring を入れることにした。

$ sudo apt install php7.4-mbstring
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
  libonig5
以下のパッケージが新たにインストールされます:
  libonig5 php7.4-mbstring
アップグレード: 0 個、新規インストール: 2 個、削除: 0 個、保留: 0 個。
538 kB のアーカイブを取得する必要があります。
この操作後に追加で 1,696 kB のディスク容量が消費されます。
続行しますか? [Y/n] Y
(中略)
E: http://xxx/php7.4/php7.4-mbstring_7.4.3-4ubuntu2.2_amd64
の取得に失敗しました  404  Not Found [IP: www.xxx.yyy.zzz 80]
E: いくつかのアーカイブを取得できません。apt-get update を実行するか --fix-missing オプションを付けて試してみてください
。
$ sudo apt update
(略)
$ $ sudo apt install php7.4-mbstring
(略)
$ laravel new blog

 _                               _
| |                             | |
| |     __ _ _ __ __ ___   _____| |
| |    / _` | '__/ _` \ \ / / _ \ |
| |___| (_| | | | (_| |\ V /  __/ |
|______\__,_|_|  \__,_| \_/ \___|_|

Creating a "laravel/laravel" project at "./blog"
Installing laravel/laravel (v8.2.0)
  - Installing laravel/laravel (v8.2.0): Loading from cache
Created project in /mnt/c/Users/username/Documents/program/blog
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - phpunit/phpunit 9.5.x-dev requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.4.x-dev requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.4.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.4.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.4.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.3.9 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.3.8 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.3.7 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.3.6 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.3.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.3.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.3.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.3.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.3.11 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.3.10 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.3.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 9.3.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - Installation request for phpunit/phpunit ^9.3 -> satisfiable by phpunit/phpunit[9.3.0, 9.3.1, 9.3.10, 9.3.11, 
      9.3.2, 9.3.3, 9.3.4, 9.3.5, 9.3.6, 9.3.7, 9.3.8, 9.3.9, 9.4.0, 9.4.1, 9.4.2, 9.4.x-dev, 9.5.x-dev].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/7.4/cli/php.ini
    - /etc/php/7.4/cli/conf.d/10-opcache.ini
    - /etc/php/7.4/cli/conf.d/10-pdo.ini
    - /etc/php/7.4/cli/conf.d/20-calendar.ini
    - /etc/php/7.4/cli/conf.d/20-ctype.ini
    - /etc/php/7.4/cli/conf.d/20-exif.ini
    - /etc/php/7.4/cli/conf.d/20-ffi.ini
    - /etc/php/7.4/cli/conf.d/20-fileinfo.ini
    - /etc/php/7.4/cli/conf.d/20-ftp.ini
    - /etc/php/7.4/cli/conf.d/20-gettext.ini
    - /etc/php/7.4/cli/conf.d/20-iconv.ini
    - /etc/php/7.4/cli/conf.d/20-json.ini
    - /etc/php/7.4/cli/conf.d/20-mbstring.ini
    - /etc/php/7.4/cli/conf.d/20-phar.ini
    - /etc/php/7.4/cli/conf.d/20-posix.ini
    - /etc/php/7.4/cli/conf.d/20-readline.ini
    - /etc/php/7.4/cli/conf.d/20-shmop.ini
    - /etc/php/7.4/cli/conf.d/20-sockets.ini
    - /etc/php/7.4/cli/conf.d/20-sysvmsg.ini
    - /etc/php/7.4/cli/conf.d/20-sysvsem.ini
    - /etc/php/7.4/cli/conf.d/20-sysvshm.ini
    - /etc/php/7.4/cli/conf.d/20-tokenizer.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
(base) $

これは困りましたね。ext-dom をキーワードにして apt-cache search しても検索がないし、 かといって dom だけキーワードにしたら一画面に収まりきらないほど多数の結果が出てくる。

    $ sudo apt-cache search php-dom
    php7.4-xml - DOM, SimpleXML, XML, and XSL module for PHP
    php-dompdf - HTML to PDF converter
    

Web ページを検索した結果を総合的俯瞰的に考慮した結果、上記の php-dom という検索に行きついた。 おそらく、この php7.4-xml のインストールで大丈夫ではないかと思った。

$ sudo apt install php7.4-xml
(略)
$ rm -r blog
$ laravel new blog
(base) $ laravel new blog

 _                               _
| |                             | |
| |     __ _ _ __ __ ___   _____| |
| |    / _` | '__/ _` \ \ / / _ \ |
| |___| (_| | | | (_| |\ V /  __/ |
|______\__,_|_|  \__,_| \_/ \___|_|

Creating a "laravel/laravel" project at "./blog"
Installing laravel/laravel (v8.2.0)
  - Installing laravel/laravel (v8.2.0): Loading from cache
Created project in /mnt/c/Users/username/Documents/program/blog
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 107 installs, 0 updates, 0 removals
  - Installing voku/portable-ascii (1.5.3): Downloading (100%)
  - Installing symfony/polyfill-php80 (v1.18.1): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.18.1): Loading from cache
  - Installing symfony/polyfill-ctype (v1.18.1): Loading from cache
  - Installing phpoption/phpoption (1.7.5): Downloading (100%)
  - Installing graham-campbell/result-type (v1.0.1): Downloading (100%)
  - Installing vlucas/phpdotenv (v5.2.0): Downloading (100%)
  - Installing symfony/css-selector (v5.1.7): Downloading (100%)
  - Installing tijsverkoyen/css-to-inline-styles (2.2.3): Downloading (100%)
  - Installing symfony/var-dumper (v5.1.7): Downloading (100%)
  - Installing symfony/deprecation-contracts (v2.2.0): Downloading (100%)
  - Installing symfony/routing (v5.1.7): Downloading (100%)
  - Installing symfony/process (v5.1.7): Loading from cache
  - Installing symfony/polyfill-intl-normalizer (v1.18.1): Loading from cache
  - Installing symfony/polyfill-intl-grapheme (v1.18.1): Loading from cache
  - Installing symfony/string (v5.1.7): Loading from cache
  - Installing symfony/polyfill-php72 (v1.18.1): Downloading (100%)
  - Installing paragonie/random_compat (v9.99.100): Downloading (100%)
  - Installing symfony/polyfill-php70 (v1.18.1): Downloading (100%)
  - Installing symfony/polyfill-intl-idn (v1.18.1): Downloading (100%)
  - Installing phpdocumentor/reflection-common (2.2.0): Downloading (100%)
  - Installing webmozart/assert (1.9.1): Downloading (100%)
  - Installing phpdocumentor/type-resolver (1.4.0): Downloading (100%)
  - Installing phpdocumentor/reflection-docblock (5.2.2): Downloading (100%)
  - Installing symfony/mime (v5.1.7): Downloading (100%)
  - Installing psr/log (1.1.3): Downloading (100%)
  - Installing symfony/polyfill-php73 (v1.18.1): Loading from cache
  - Installing symfony/http-foundation (v5.1.7): Downloading (100%)
  - Installing symfony/http-client-contracts (v2.3.1): Downloading (100%)
  - Installing psr/container (1.0.0): Loading from cache
  - Installing psr/event-dispatcher (1.0.0): Downloading (100%)
  - Installing symfony/event-dispatcher-contracts (v2.2.0): Downloading (100%)
  - Installing symfony/event-dispatcher (v5.1.7): Downloading (100%)
  - Installing symfony/error-handler (v5.1.7): Downloading (100%)
  - Installing symfony/http-kernel (v5.1.7): Downloading (100%)
  - Installing symfony/finder (v5.1.7): Downloading (100%)
  - Installing symfony/service-contracts (v2.2.0): Loading from cache
  - Installing symfony/console (v5.1.7): Loading from cache
  - Installing symfony/polyfill-iconv (v1.18.1): Downloading (100%)
  - Installing doctrine/lexer (1.2.1): Downloading (100%)
  - Installing egulias/email-validator (2.1.22): Downloading (100%)
  - Installing swiftmailer/swiftmailer (v6.2.3): Downloading (100%)
  - Installing brick/math (0.9.1): Downloading (100%)
  - Installing ramsey/collection (1.1.1): Downloading (100%)
  - Installing ramsey/uuid (4.1.1): Downloading (100%)
  - Installing psr/simple-cache (1.0.1): Downloading (100%)
  - Installing opis/closure (3.6.0): Downloading (100%)
  - Installing symfony/translation-contracts (v2.3.0): Downloading (100%)
  - Installing symfony/translation (v5.1.7): Downloading (100%)
  - Installing nesbot/carbon (2.41.3): Downloading (100%)
  - Installing monolog/monolog (2.1.1): Downloading (100%)
  - Installing league/mime-type-detection (1.5.1): Downloading (100%)
  - Installing league/flysystem (1.1.3): Downloading (100%)
  - Installing league/commonmark (1.5.6): Downloading (100%)
  - Installing dragonmantank/cron-expression (v3.0.2): Downloading (100%)
  - Installing doctrine/inflector (2.0.3): Downloading (100%)
  - Installing laravel/framework (v8.11.2): Downloading (100%)
  - Installing fideloper/proxy (4.4.0): Downloading (100%)
  - Installing asm89/stack-cors (v2.0.1): Downloading (100%)
  - Installing fruitcake/laravel-cors (v2.0.2): Downloading (100%)
  - Installing psr/http-message (1.0.1): Downloading (100%)
  - Installing psr/http-client (1.0.1): Downloading (100%)
  - Installing ralouphie/getallheaders (3.0.3): Downloading (100%)
  - Installing guzzlehttp/psr7 (1.7.0): Downloading (100%)
  - Installing guzzlehttp/promises (1.4.0): Downloading (100%)
  - Installing guzzlehttp/guzzle (7.2.0): Downloading (100%)
  - Installing dnoegel/php-xdg-base-dir (v0.1.1): Downloading (100%)
  - Installing nikic/php-parser (v4.10.2): Downloading (100%)
  - Installing psy/psysh (v0.10.4): Downloading (100%)
  - Installing laravel/tinker (v2.4.2): Downloading (100%)
  - Installing scrivo/highlight.php (v9.18.1.3): Downloading (100%)
  - Installing filp/whoops (2.9.0): Downloading (100%)
  - Installing facade/ignition-contracts (1.0.2): Downloading (100%)
  - Installing facade/flare-client-php (1.3.7): Downloading (100%)
  - Installing facade/ignition (2.4.1): Downloading (100%)
  - Installing fzaninotto/faker (v1.9.1): Downloading (100%)
  - Installing hamcrest/hamcrest-php (v2.0.1): Downloading (100%)
  - Installing mockery/mockery (1.4.2): Downloading (100%)
  - Installing nunomaduro/collision (v5.0.2): Downloading (100%)
  - Installing sebastian/version (3.0.2): Downloading (100%)
  - Installing sebastian/type (2.3.0): Downloading (100%)
  - Installing sebastian/resource-operations (3.0.3): Downloading (100%)
  - Installing sebastian/recursion-context (4.0.3): Downloading (100%)
  - Installing sebastian/object-reflector (2.0.3): Downloading (100%)
  - Installing sebastian/object-enumerator (4.0.3): Downloading (100%)
  - Installing sebastian/global-state (5.0.1): Downloading (100%)
  - Installing sebastian/exporter (4.0.3): Downloading (100%)
  - Installing sebastian/environment (5.1.3): Downloading (100%)
  - Installing sebastian/diff (4.0.3): Downloading (100%)
  - Installing sebastian/comparator (4.0.5): Downloading (100%)
  - Installing sebastian/code-unit (1.0.7): Downloading (100%)
  - Installing sebastian/cli-parser (1.0.1): Downloading (100%)
  - Installing phpunit/php-timer (5.0.2): Downloading (100%)
  - Installing phpunit/php-text-template (2.0.3): Downloading (100%)
  - Installing phpunit/php-invoker (3.1.1): Downloading (100%)
  - Installing phpunit/php-file-iterator (3.0.5): Downloading (100%)
  - Installing sebastian/complexity (2.0.1): Downloading (100%)
  - Installing sebastian/lines-of-code (1.0.1): Downloading (100%)
  - Installing theseer/tokenizer (1.2.0): Downloading (100%)
  - Installing sebastian/code-unit-reverse-lookup (2.0.3): Downloading (100%)
  - Installing phpunit/php-code-coverage (9.2.0): Downloading (100%)
  - Installing doctrine/instantiator (1.3.1): Downloading (100%)
  - Installing phpspec/prophecy (1.12.1): Downloading (100%)
  - Installing phar-io/version (3.0.2): Downloading (100%)
  - Installing phar-io/manifest (2.0.1): Downloading (100%)
  - Installing myclabs/deep-copy (1.10.1): Downloading (100%)
  - Installing phpunit/phpunit (9.4.2): Downloading (100%)
voku/portable-ascii suggests installing ext-intl (Use Intl for transliterator_transliterate() support)
symfony/var-dumper suggests installing ext-intl (To show region name in time zone dump)
symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader)
symfony/routing suggests installing symfony/yaml (For using the YAML loader)
symfony/routing suggests installing symfony/expression-language (For using expression matching)
symfony/routing suggests installing doctrine/annotations (For using the annotation loader)
symfony/polyfill-intl-normalizer suggests installing ext-intl (For best performance)
symfony/polyfill-intl-grapheme suggests installing ext-intl (For best performance)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
symfony/polyfill-intl-idn suggests installing ext-intl (For best performance)
symfony/http-client-contracts suggests installing symfony/http-client-implementation
symfony/event-dispatcher suggests installing symfony/dependency-injection
symfony/http-kernel suggests installing symfony/browser-kit
symfony/http-kernel suggests installing symfony/config
symfony/http-kernel suggests installing symfony/dependency-injection
symfony/service-contracts suggests installing symfony/service-implementation
symfony/console suggests installing symfony/lock
egulias/email-validator suggests installing ext-intl (PHP Internationalization Libraries are required to use the SpoofChecking validation)
swiftmailer/swiftmailer suggests installing ext-intl (Needed to support internationalized email addresses)
swiftmailer/swiftmailer suggests installing true/punycode (Needed to support internationalized email addresses, if ext-intl is not installed)
ramsey/uuid suggests installing ext-bcmath (Enables faster math with arbitrary-precision integers using BCMath.)
ramsey/uuid suggests installing ext-gmp (Enables faster math with arbitrary-precision integers using GMP.)
ramsey/uuid suggests installing ext-uuid (Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.)
ramsey/uuid suggests installing ramsey/uuid-doctrine (Allows the use of Ramsey\Uuid\Uuid as Doctrine field type.)
ramsey/uuid suggests installing paragonie/random-lib (Provides RandomLib for use with the RandomLibAdapter)
symfony/translation suggests installing symfony/config
symfony/translation suggests installing symfony/yaml
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing elasticsearch/elasticsearch (Allow sending log messages to an Elasticsearch server via official client)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongodb (Allow sending log messages to a MongoDB server (via driver))
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server (via library))
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem)
league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files)
league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage)
league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2)
league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3)
league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage)
league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications)
league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching)
league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib)
league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
laravel/framework suggests installing ext-gd (Required to use Illuminate\Http\Testing\FileFactory::image().)
laravel/framework suggests installing ext-memcached (Required to use the memcache cache driver.)
laravel/framework suggests installing ext-redis (Required to use the Redis cache and queue drivers (^4.0|^5.0).)
laravel/framework suggests installing aws/aws-sdk-php (Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.0).)
laravel/framework suggests installing doctrine/dbal (Required to rename columns and drop SQLite columns (^2.6).)
laravel/framework suggests installing league/flysystem-aws-s3-v3 (Required to use the Flysystem S3 driver (^1.0).)
laravel/framework suggests installing league/flysystem-cached-adapter (Required to use the Flysystem cache (^1.0).)
laravel/framework suggests installing league/flysystem-sftp (Required to use the Flysystem SFTP driver (^1.0).)
laravel/framework suggests installing nyholm/psr7 (Required to use PSR-7 bridging features (^1.2).)
laravel/framework suggests installing pda/pheanstalk (Required to use the beanstalk queue driver (^4.0).)
laravel/framework suggests installing predis/predis (Required to use the predis connector (^1.1.2).)
laravel/framework suggests installing pusher/pusher-php-server (Required to use the Pusher broadcast driver (^4.0).)
laravel/framework suggests installing symfony/cache (Required to PSR-6 cache bridge (^5.1).)
laravel/framework suggests installing symfony/filesystem (Required to enable support for relative symbolic links (^5.1).)
laravel/framework suggests installing symfony/psr-http-message-bridge (Required to use PSR-7 bridging features (^2.0).)
laravel/framework suggests installing wildbit/swiftmailer-postmark (Required to use Postmark mail driver (^3.0).)
guzzlehttp/psr7 suggests installing laminas/laminas-httphandlerrunner (Emit PSR-7 responses)
guzzlehttp/guzzle suggests installing ext-curl (Required for CURL handler support)
guzzlehttp/guzzle suggests installing ext-intl (Required for Internationalized Domain Name (IDN) support)
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.)
filp/whoops suggests installing whoops/soap (Formats errors as SOAP responses)
facade/ignition suggests installing laravel/telescope (^3.1)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/php-code-coverage suggests installing ext-pcov (*)
phpunit/php-code-coverage suggests installing ext-xdebug (*)
phpunit/phpunit suggests installing ext-soap (*)
phpunit/phpunit suggests installing ext-xdebug (*)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
73 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan key:generate --ansi
Application key set successfully.

Application ready! Build something amazing.

やっとのことでたどり着いた。しかし、パッケージを 107 本もインストールしなければならないとはねえ。 煩悩の数に一つ足りないのは何か意味があるのだろうか。

起動する

起動を試みた。

    $ cd blog
    $ php artisan serve
    Starting Laravel development server: http://127.0.0.1:8000
    [Thu Oct 22 14:03:49 2020] PHP 7.4.3 Development Server (http://127.0.0.1:8000) started
    [Thu Oct 22 14:04:20 2020] 127.0.0.1:50995 Accepted
    [Thu Oct 22 14:04:20 2020] 127.0.0.1:50996 Accepted
    [Thu Oct 22 14:04:21 2020] 127.0.0.1:50996 Closing
    [Thu Oct 22 14:04:22 2020] 127.0.0.1:50995 [200]: GET /favicon.ico
    [Thu Oct 22 14:04:22 2020] 127.0.0.1:50995 Closing    

ブラウザで http://127.0.0.1:8000 にアクセスすると、Laravel の画面が出てきた。万歳。 いったんここで終える(2020/10/22)

まりんきょ学問所コンピュータの部屋 > Laravel をしらべる


MARUYAMA Satosi