Laravel 工匠忽略了我的 app/config/database.php
Posted
技术标签:
【中文标题】Laravel 工匠忽略了我的 app/config/database.php【英文标题】:Laravel artisan ignoring my app/config/database.php 【发布时间】:2013-10-20 16:56:07 【问题描述】:我正在尝试从 Laravel 完成快速安装指南,但是在使用 artisan 数据库工具时出现以下错误:
php artisan migrate --verbose
[PDOException]
could not find driver
Exception trace:
() at /var/www/html/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:47
PDO->__construct() at /var/www/html/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:47
Illuminate\Database\Connectors\Connector->createConnection() at /var/www/html/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/mysqlConnector.php:20
Illuminate\Database\Connectors\MySqlConnector->connect() at /var/www/html/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:41
Illuminate\Database\Connectors\ConnectionFactory->make() at /var/www/html/project/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:128
Illuminate\Database\DatabaseManager->makeConnection() at /var/www/html/project/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:64
Illuminate\Database\DatabaseManager->connection() at /var/www/html/project/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php:169
Illuminate\Database\Migrations\DatabaseMigrationRepository->getConnection() at /var/www/html/project/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php:137
Illuminate\Database\Migrations\DatabaseMigrationRepository->repositoryExists() at /var/www/html/project/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:370
Illuminate\Database\Migrations\Migrator->repositoryExists() at /var/www/html/project/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:95
Illuminate\Database\Console\Migrations\MigrateCommand->prepareDatabase() at /var/www/html/project/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:58
Illuminate\Database\Console\Migrations\MigrateCommand->fire() at /var/www/html/project/vendor/laravel/framework/src/Illuminate/Console/Command.php:108
Illuminate\Console\Command->execute() at /var/www/html/project/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:244
Symfony\Component\Console\Command\Command->run() at /var/www/html/project/vendor/laravel/framework/src/Illuminate/Console/Command.php:96
Illuminate\Console\Command->run() at /var/www/html/project/vendor/symfony/console/Symfony/Component/Console/Application.php:897
Symfony\Component\Console\Application->doRunCommand() at /var/www/html/project/vendor/symfony/console/Symfony/Component/Console/Application.php:191
Symfony\Component\Console\Application->doRun() at /var/www/html/project/vendor/symfony/console/Symfony/Component/Console/Application.php:121
Symfony\Component\Console\Application->run() at /var/www/html/project/artisan:59
MySqlConnector
上的错误很奇怪,因为我在 app/config/database.php:
上配置了 Postgres
'default' => 'pgsql'
工匠是否以某种方式忽略了我的配置?有什么简单的方法可以强制他使用自定义的配置文件?
PS:是的,我的 pdo_pgsql 已包含在内并且可以正常工作(经过测试)。
【问题讨论】:
您有php5-pgsql
扩展名吗?你在运行什么操作系统?
我正在运行 Fedora 18,我有最新版本的 php-pgsql。我用PDO("pgsql:host=localhost;dbname=test", "username", "password");
测试了它的工作原理。
【参考方案1】:
在运行composer update
之后,工匠开始正确使用我的配置。
【讨论】:
还要确保你没有使用多个版本的php,这是我通过phpbrew
做的,所以composer使用的是通过phpbrew安装的php版本而不是系统版本以上是关于Laravel 工匠忽略了我的 app/config/database.php的主要内容,如果未能解决你的问题,请参考以下文章