简体   繁体   中英

Cannot install barryvdh/laravel-dompdf

I could not install barryvdh/laravel-dompdf using composer require barryvdh/laravel-dompdf .

The error I got was:

[Invalid argument exception] Could not find a matching version of barryvdh/laravel-dompdf. Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability (dev).

So in order to fix the error, I included barryvdh/laravel-dompdf: master@dev in composer.json and did a composer update . This time it gave me the error:

The requested package barryvdh/laravel-dompdf could not be found in any version. there may be a typo in the package name

Below is my composer.json:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "guzzlehttp/guzzle": "^6.3",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "barryvdh/laravel-dompdf": "master@dev"
    },
    "repositories":
    [
        {
          "type": "composer",
          "url": "https:\/\/www.phpclasses.org\/"
        },
        {
          "packagist": false
        }
    ],
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "app/includes",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

What do you think I am missing here?

Use

"barryvdh/laravel-dompdf": "^0.8.4",

instead of

"barryvdh/laravel-dompdf": "master@dev"

Usually, it is advisable not to edit composer.json directly when installing third-party packages. You can remove the line "barryvdh/laravel-dompdf": "master@dev" from your file, and run this command from your project root directory instead:

composer require barryvdh/laravel-dompdf

It installs the latest stable third-party package and automatically updates both composer.json and composer.lock files.

UPDATE: To solve the problem with your composer.json file, change the repositories key to this:

"repositories" : 
[
    {
        "type": "composer",
        "url": "https://packagist.org"
    },
    {
        "packagist": false
    }
]

Remove this line in your composer.json file

"require": {
    "barryvdh/laravel-dompdf": "master@dev"
}, 

After, run this command in your command prompt

composer require barryvdh/laravel-dompdf

This will download the package and the dompdf + fontlib libraries also. This will generate the latest version for your project

Please Check this: barryvdh/laravel-dompdf

The package got installed after removing the repositories section from my composer.json.

Thank you all for the help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM