当我生成命令“php composer.phar install”时,我收到以下错误:
{“error”:{“type”:“PDOException”,“message”:“SQLSTATE [42000] [1044]拒绝用户''@ localhost'访问数据库'database'”,“file”: “/var/www/wingtech/wingadmin/public_html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php","line":47}}Script php artisan optimize处理post-install-cmd事件返回时出错
http://oi42.tinypic.com/20uc2ma.jpg
奇怪的是,当我在运行安装组合器之前在app / config / database.php中设置数据库时,不会出现此错误
为了简化我的php版本是5.4.17
我的composer.json是:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.0.*",
"orchestra/asset": "2.0.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/library",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev"
}
有谁知道会是什么?
答案 0 :(得分:2)
您可以使用以下开关在没有运行Laravel脚本的情况下运行Composer:
php composer.phar install --no-scripts
答案 1 :(得分:0)
在php<运行时发生了类似行为(工匠优化返回错误) 5.3或者有多个php版本并且需要在命令行中指定php版本,即php542 composer.phar install - similar issue here.
但是PDO异常很奇怪,你能检查一下composer.json的脚本部分吗?那里有什么比默认的东西还多吗?
答案 2 :(得分:0)
你有.env文件吗?当.env文件丢失时,这是工匠脚本的典型错误。