Laravel 更新/安装 composer 包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48697176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:22:04  来源:igfitidea点击:

Laravel Update / install composer package

phplaravelpaypalcomposer-php

提问by Nasser Ali Karimi

Can you answer me? I use the latest version of Laravel and I want to add to my project the PayPal service. I want to install some package to Laravel and added this 2 rows to composer.json

你可以回答我吗?我使用最新版本的 Laravel,我想将 PayPal 服务添加到我的项目中。我想安装一些包到 Laravel 并将这 2 行添加到 composer.json

"guzzlehttp/guzzle": "~5.2",

"paypal/rest-api-sdk-php": "*"

My composer.json file

我的 composer.json 文件

   {
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=7.0.0",
        "fideloper/proxy": "~3.3",
        "laravel/framework": "5.5.*",
        "laravel/tinker": "~1.0"
    },
    "require-dev": {
        "filp/whoops": "~2.0",
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~6.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "/usr/local/bin/php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "/usr/local/bin/php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "/usr/local/bin/php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true,
    "cache-dir": "/home/iamdevco/public_html/norrisms/designer/cache"
    },
    "guzzlehttp/guzzle": "~5.2",

"paypal/rest-api-sdk-php": "*"
}

but I get this error after download packages

但我在下载软件包后收到此错误

$ composer update

Loading composer repositories with package information Updating dependencies (including require-dev) Nothing to install or update Generating optimized autoload files

使用包信息加载 Composer 存储库 更新依赖项(包括 require-dev) 无需安装或更新 生成优化的自动加载文件

Illuminate\Foundation\ComposerScripts::postAutoloadDump /usr/local/bin/php artisan package:discover The system cannot find the path specified. Script /usr/local/bin/php artisan package:discover handling the post-autoload-dump event returned with error code 1

Illuminate\Foundation\ComposerScripts::postAutoloadDump /usr/local/bin/php artisan package:discover 系统找不到指定的路径。脚本 /usr/local/bin/php artisan package:discover 处理返回的 post-autoload-dump 事件,错误代码为 1

回答by TharinduLucky

Rather than manually writing the composer.json, try installing and adding them with the specific commands. Like this.

不要手动编写composer.json,而是尝试使用特定命令安装和添加它们。像这样。

composer require paypal/rest-api-sdk-php

composer require guzzlehttp/guzzle

That way, you'll avoid any typos and composer.jsonfile will be kept as pure as possible.

这样,您将避免任何拼写错误,并且composer.json文件将尽可能保持纯净。

回答by R Santos

Try this composer require paypal/rest-api-sdk-php

尝试这个 composer require paypal/rest-api-sdk-php

Ref: https://packagist.org/packages/paypal/rest-api-sdk-php

参考:https: //packagist.org/packages/paypal/rest-api-sdk-php

Edit: remove the paypal/rest-api-sdk-php on the composer.json and the guzzle then try this

编辑:删除 composer.json 和 guzzle 上的 paypal/rest-api-sdk-php 然后试试这个

composer require guzzlehttp/guzzle