php artisan migrate - Laravel

问题描述:

As soon, i press Enter 'php artisan migrate' command on ubuntu terminal. Error coming like:- [PDOException] Could Not Find Driver

I'm not able to fix this problem as i'm new to it.

Please help me to fix this issue.

enter image description here enter image description here

我很快就在ubuntu终端上输入'php artisan migrate'命令。 出现错误: - [PDOException]无法找到驱动程序 strong> p>

我无法修复此问题,因为我不熟悉它。 p >

请帮我解决这个问题。 p>

p> div>

I made changes in "Project-Folder-Name/config/database.php". And, it worked. Added 'unix_socket' => '/opt/lampp/var/mysql/mysql.sock',

'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'DatabaseName'),
            'username'  => env('DB_USERNAME', 'root'),
            'password'  => env('DB_PASSWORD', ''),
        'unix_socket'   => '/opt/lampp/var/mysql/mysql.sock', //Your sock got from above
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

Yo should be enable the PDO extension for you Database Manager in you php.ini

;extension=php_pdo_firebird.dll
;extension=php_pdo_mssql.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll //In my Case the extension enable is for pgsql
;extension=php_pdo_sqlite.dll

For enable you should delete the ; char in the line of the extension restart the server and voila

I think you have a seperated configuration file (php.ini) for your CLI.

Try to execute php -i | grep php.ini in your console. And enable the required modules in that file.

It should return something like this:

sander@sander-Laptop:~$ php -i | grep php.ini
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini

As you can see it uses another php.ini file then what the phpinfo(); returns

Open that file and enable the required extensions there

so change the lines of the extensions that you require: ;extension=extension.so to extension=extension.so

Also a tip: If you use Laravel you can use the Homestead (vagrant, virtualbox) which is an virtual machine complete preinstalled for you laravel application

http://laravel.com/docs/5.1/homestead