Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php “拉拉维尔家园”;找不到驱动程序“;使用git终端时_Php_Git_Laravel_Ssh_Homestead - Fatal编程技术网

Php “拉拉维尔家园”;找不到驱动程序“;使用git终端时

Php “拉拉维尔家园”;找不到驱动程序“;使用git终端时,php,git,laravel,ssh,homestead,Php,Git,Laravel,Ssh,Homestead,当我在windows上使用git终端并尝试运行“php artisan migrate”来迁移我的表时,出现以下错误: 1异常::(“找不到驱动程序”) 但是,当我通过ssh登录到我的虚拟框“vagrant ssh”时,当我导航到站点文件夹并运行“php artisan migrate”时,它工作得非常好 为什么会这样?我怎样才能修好它 完整错误消息: $ php artisan migrate Illuminate\Database\QueryException : could no

当我在windows上使用git终端并尝试运行“php artisan migrate”来迁移我的表时,出现以下错误:

1异常::(“找不到驱动程序”)

但是,当我通过ssh登录到我的虚拟框“vagrant ssh”时,当我导航到站点文件夹并运行“php artisan migrate”时,它工作得非常好

为什么会这样?我怎样才能修好它

完整错误消息:

$ php artisan migrate

   Illuminate\Database\QueryException  : could not find driver (SQL: select * fr
om information_schema.tables where table_schema = aff and table_name = migration
s)

  at C:\Users\jarro\Documents\sites\aff\vendor\laravel\framework\src\Illuminate\
Database\Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll
 format the error
    661|         // message to include the bindings with SQL, which will make th
is exception a
    662|         // lot more helpful to the developer instead of just the databa
se's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668|

  Exception trace:

  1   PDOException::("could not find driver")
      C:\Users\jarro\Documents\sites\aff\vendor\laravel\framework\src\Illuminate
\Database\Connectors\Connector.php:68

  2   PDO::__construct("mysql:host=192.168.10.10;port=3306;dbname=aff", "homeste
ad", "secret", [])
      C:\Users\jarro\Documents\sites\aff\vendor\laravel\framework\src\Illuminate
\Database\Connectors\Connector.php:68

  Please use the argument -v to see more details.

当您使用
php artisan migrate
或seed时,您需要进入homestead虚拟机终端并运行这些命令,否则它将失败,因为它将发现虚拟机mysql而不是您的windows mysql

  • homestead ssh
  • cd-code/yourapp
  • php-artisan-migrate
    php-artisan-db:seed

  • 我假设您有像navicat或任何可以访问mysql虚拟机内部的数据库查看器来跟踪您的命令是否正常工作。

    我发现这样做效果更好。虽然你可以按照Winston说的做(标记正确答案),但我删除了AMPP,下载了Xampp,重新安装了composer,并将php exe路径放到了Xampp。现在我可以在本地机器上做任何事情,而不是在虚拟机上


    我只是想把这个放在这里!:D

    我也遇到了同样的问题,这是因为/.env文件中的数据库主机错误:

    DB_HOST=127.0.0.1

    将其设置为您的流浪主人(homestead.test for me):

    DB_主机=宅地测试

    应已将其映射到Windows“主机”文件中:

    192.168.10.10宅地测试


    尝试销毁流浪者虚拟机,然后再次运行流浪者。这将重新创建您的流浪虚拟机

    从流浪者文件所在的Homestead文件夹中的终端运行这些命令

    命令:

  • 流浪破坏——强制执行
  • vagrant up

  • 您是否在本地计算机上安装了
    mysql
    ?您是否检查了
    php-m
    中的
    pdo_mysql
    扩展名?@Spholt是的,我确实安装了Ammps。它附带MySQL。我需要卸载此文件并重试吗?@mim
    php-m
    将PDO作为选项之一,所以我猜它已经安装好了!能否使用异常中提供的凭据通过命令行连接到数据库?(
    host=192.168.10.10;port=3306;dbname=aff
    )。你的宅地盒子在运转吗?我将开始这样做:谢谢你的支持