1
votes

When I generate the command "php composer.phar install" I get the following error:

{"error":{"type":"PDOException","message":"SQLSTATE[42000] [1044] Access denied for user ''@'localhost' to database 'database'","file":"/var/www/wingtech/wingadmin/public_html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php","line":47}}Script php artisan optimize handling the post-install-cmd event returned with an error

http://oi42.tinypic.com/20uc2ma.jpg

Curiously, when I set up a database in app/config/database.php before running the install of the composer this error does not appear

To ease my php version is 5.4.17

And my composer.json is:

{
"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"
}

Does anyone know what could be?

3

3 Answers

2
votes

You can run Composer without it running Laravel scripts using the following switch:

php composer.phar install --no-scripts
0
votes

Similar behavior (artisan optimize returning an error) happened when running on php < 5.3 or with multiple php versions and needing to specify the php version in the command line, ie php542 composer.phar install - similar issue here.

But the PDO exception is weird, could you check the scripts part of composer.json ? Is there anything more than the default stuff there?

0
votes

Do you have an .env file? This is a typical error of the artisan script when the .env file is missing.