Composer.json 文件已重新创建为 .lock 文件,现在在 PHP 中导致 artisan 错误

Composer.json file has been recreated as .lock file and now is causing artisan errors in PHP

我正在尝试在 Laravel 中制作一个新控制器。当我将此命令键入我的 CMD window:

php artisan make:controller CheckoutController

我遇到了这个错误

   ErrorException  : file_get_contents(C:\xampp\htdocs\iezonsolutions\composer.j
son): failed to open stream: No such file or directory

  at C:\xampp\htdocs\iezonsolutions\vendor\laravel\framework\src\Illuminate\Foun
dation\Application.php:1155
    1151|         if (! is_null($this->namespace)) {
    1152|             return $this->namespace;
    1153|         }
    1154|
  > 1155|         $composer = json_decode(file_get_contents(base_path('composer.
json')), true);
    1156|
    1157|         foreach ((array) data_get($composer, 'autoload.psr-4') as $nam
espace => $path) {
    1158|             foreach ((array) $path as $pathChoice) {
    1159|                 if (realpath(app_path()) == realpath(base_path().'/'.$
pathChoice)) {

  Exception trace:

  1   file_get_contents("C:\xampp\htdocs\iezonsolutions\composer.json")
      C:\xampp\htdocs\iezonsolutions\vendor\laravel\framework\src\Illuminate\Fou
ndation\Application.php:1155

  2   Illuminate\Foundation\Application::getNamespace()
      C:\xampp\htdocs\iezonsolutions\vendor\laravel\framework\src\Illuminate\Con
sole\GeneratorCommand.php:225

我在将 Stripe PHP 安装到我的作曲家后才开始收到此错误:

composer global require stripe/stripe-php

这给了我输出:

C:\xampp\htdocs\iezonsolutions>composer global require stripe/stripe-php
Changed current directory to C:/Users/user/AppData/Roaming/Composer
Using version ^6.28 for stripe/stripe-php
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing stripe/stripe-php (v6.28.0): Loading from cache
Writing lock file

这似乎删除了我的 composer.json 文件并重新创建为 .lock 文件。我该如何解决这个问题?

请尝试以下步骤:

  1. 删除.lock文件
  2. 来自您的应用程序目录 运行 composer require stripe/stripe-php (非全局)
  3. 您可能需要重新运行作曲家安装或作曲家更新