尝试在laravel 5.1 mac上安装php phantom js时,Composer安装错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了尝试在laravel 5.1 mac上安装php phantom js时,Composer安装错误相关的知识,希望对你有一定的参考价值。

我试图在laravel 5.1上安装php幻影js,但不断得到一个奇怪的错误:

“Class PhantomInstaller Installer不能自动加载,无法调用post-install-cmd脚本”

我已经将以下内容写入我的composer.json文件,在我的root中添加了一个bin文件夹,然后运行composer install,但无济于事:

"require": {
        "jonnyw/php-phantomjs": "3.*"
    },
    "config": {
        "bin-dir": "bin"
    },
    "scripts": {
        "post-install-cmd": [
            "PhantomInstaller\Installer::installPhantomJS"
        ],
        "post-update-cmd": [
            "PhantomInstaller\Installer::installPhantomJS"
        ]
    }

有谁知道什么可能是错的?

答案

有相同的错误,通过安装@dev版本修复。

这是我的composer.json,它工作正常。

{
  "type": "project",
  "license": "proprietary",
  "require": {
    "php": "^7.1.3",
    "ext-ctype": "*",
    "ext-iconv": "*",
    "google/apiclient": "^2.2",
    "jonnyw/php-phantomjs": "@dev",
    "keboola/csv": "^2.0",
    "rtheunissen/guzzle-log-middleware": "^0.4.1",
    "secit-pl/imap-bundle": "^1.3",
    "sensio/framework-extra-bundle": "^5.2",
    "smalot/pdfparser": "^0.13.2",
    "symfony/cache": "*",
    "symfony/console": "*",
    "symfony/flex": "^1.1",
    "jakoch/phantomjs-installer": "2.1.1-p09",
    "symfony/framework-bundle": "*",
    "symfony/yaml": "*"
  },
  "require-dev": {
    "neronmoon/scriptsdev": "dev-master",
    "symfony/dotenv": "*"
  },
  "config": {
    "bin-dir": "bin",
    "preferred-install": {
      "*": "dist"
    },
    "sort-packages": true
  },
  "autoload": {
    "psr-4": {
      "App\": "src/"
    }
  },
  "autoload-dev": {
    "psr-4": {
      "App\Tests\": "tests/"
    }
  },
  "replace": {
    "paragonie/random_compat": "*",
    "symfony/polyfill-ctype": "*",
    "symfony/polyfill-iconv": "*",
    "symfony/polyfill-php71": "*",
    "symfony/polyfill-php70": "*",
    "symfony/polyfill-php56": "*"
  },
  "scripts": {
    "auto-scripts": {
      "cache:clear": "symfony-cmd",
      "assets:install %PUBLIC_DIR%": "symfony-cmd"
    },
    "post-install-cmd": [
      "@auto-scripts"
    ],
    "post-update-cmd": [
      "@auto-scripts"
    ]
  },
  "conflict": {
    "symfony/symfony": "*"
  },

  "extra": {
    "scripts-dev": {
      "post-install-cmd": [
        "PhantomInstaller\Installer::installPhantomJS"
      ],
      "post-update-cmd": [
        "PhantomInstaller\Installer::installPhantomJS"
      ]
    },
    "symfony": {
      "require": "4.1.*"
    }
  }
}

希望这有助于解决问题。

以上是关于尝试在laravel 5.1 mac上安装php phantom js时,Composer安装错误的主要内容,如果未能解决你的问题,请参考以下文章

我如何在 mac high sierra 上安装 Laravel 8

尝试使用 composer 安装 laravel 时 php 版本出错

laravel 5.1部署到 集成环境 lnmp上

尝试在我的 Mac 上安装 Composer,Brew 失败

全新安装 Laravel 5.1 时出错

/Applications/XAMPP/xamppfiles/bin/php - Xampp Mac 上的 Laravel