Laravelインストーラを使ってインストールした時にエラーが起きた場合の対処法です。
問題
$ laravel new project-name
Crafting application...
PHP Fatal error: Uncaught Error: Call to undefined method Symfony\Component\Process\Process::fromShellCommandline() in /Users/ucan/.composer/vendor/laravel/installer/src/NewCommand.php:84
Stack trace:
#0 /Users/ucan/.composer/vendor/symfony/console/Command/Command.php(251): Laravel\Installer\Console\NewCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /Users/ucan/.composer/vendor/symfony/console/Application.php(886): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /Users/ucan/.composer/vendor/symfony/console/Application.php(262): Symfony\Component\Console\Application->doRunCommand(Object(Laravel\Installer\Console\NewCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /Users/ucan/.composer/vendor/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun in /Users/ucan/.composer/vendor/laravel/installer/src/NewCommand.php on line 84
Fatal error: Uncaught Error: Call to undefined method Symfony\Component\Process\Process::fromShellCommandline() in /Users/ucan/.composer/vendor/laravel/installer/src/NewCommand.php:84
Stack trace:
#0 /Users/ucan/.composer/vendor/symfony/console/Command/Command.php(251): Laravel\Installer\Console\NewCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /Users/ucan/.composer/vendor/symfony/console/Application.php(886): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /Users/ucan/.composer/vendor/symfony/console/Application.php(262): Symfony\Component\Console\Application->doRunCommand(Object(Laravel\Installer\Console\NewCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /Users/ucan/.composer/vendor/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun in /Users/ucan/.composer/vendor/laravel/installer/src/NewCommand.php on line 84
Laravelインストーラが古いので更新しましょう...😅
対策
$ composer global update
ディレクトリは作成されてるので削除してやり直しましょう。
$ rm -rf project-name
$ laravel new project-name
$ php artisan -V
Laravel Framework 7.10.3
バージョン表示できたらokです。