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

时间:2019-01-14 16:12:55

标签: php laravel composer-php artisan

我正在尝试在Laravel中创建一个新的控制器。当我在CMD窗口中键入以下命令时:

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 个答案:

答案 0 :(得分:2)

尝试以下步骤:

  1. 删除.lock文件
  2. 从您的应用程序目录运行composer require stripe/stripe-php (不全局)
  3. 您可能必须重新运行composer安装或composer更新