我正在尝试在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
文件。我该如何解决?
答案 0 :(得分:2)
尝试以下步骤:
composer require stripe/stripe-php
(不全局)