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

artisan したら PHP Parse error: syntax error, unexpected token ")" と Class "DOMDocument" not found が出た

Posted at

Laravel のプロジェクトを人任せにしていたが自分の所でも開発をしなければならなくなったので、マイグレーションを作りたく artisan を使ってみたが、

$ php artisan make:migration add_hoge_to_fugas --table=fugas
PHP Parse error:  syntax error, unexpected token ")" in /home/test/projects/hogehoge-system/vendor/symfony/console/SignalRegistry/SignalRegistry.php on line 37

こんなエラーが出ますね。これは PHP のバージョンじゃなかろうか。WSL2 にはいってるのは

$ php -version
PHP 8.0.17 (cli) (built: Mar 20 2022 17:04:09) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.17, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.17, Copyright (c), by Zend Technologies

8.0.17 だったのであげてみる。

$sudo apt update
$sudo apt install -y php

公式からアップデートするだけで 8.1 系になりました。

$  php -version
PHP 8.1.9 (cli) (built: Aug 15 2022 09:39:52) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.9, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.9, Copyright (c), by Zend Technologies

もっかいマイグレーションしたら、

Class "DOMDocument" not found

  at vendor/nunomaduro/termwind/src/HtmlRenderer.php:32
     28▕      * Parses the given html.
     29▕      */
     30▕     public function parse(string $html): Components\Element
     31▕     {
  ➜  32▕         $dom = new DOMDocument();
     33▕ 
     34▕         if (strip_tags($html) === $html) {
     35▕             return Termwind::span($html);
     36▕         }

      +21 vendor frames 
  22  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

こんなことになったので php-xml をアップデートした。

$ sudo apt-get install php8.1-xml

はいこれで成功

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?