Viewed   82 times

I am trying to install Laravel. I have installed Xampp, but when I try to setup my database using php artisan migrateI get the error:

[IlluminateDatabaseQueryException] could not find driver (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations) [PDOException] could not find driver

config/database.php file has the relevant connections:

'connections' => [

    'sqlite' => [
        'driver' => 'sqlite',
        'database' => env('DB_DATABASE', database_path('database.sqlite')),
        'prefix' => '',
    ],

    'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ],

    'pgsql' => [
        'driver' => 'pgsql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '5432'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8',
        'prefix' => '',
        'schema' => 'public',
        'sslmode' => 'prefer',
    ],

    'sqlsrv' => [
        'driver' => 'sqlsrv',
        'host' => env('DB_HOST', 'localhost'),
        'port' => env('DB_PORT', '1433'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8',
        'prefix' => '',
    ],

],

Any ideas?

 Answers

1

In your php.ini configuration file simply uncomment the extension:

;extension=php_pdo_mysql.dll

(You can find your php.ini file in the php folder where your stack server is installed.)

If you're on Windows make it: extension=php_pdo_mysql.dll

If you're on Linux make it: extension=pdo_mysql.so

And do a quick server restart.

If this isn't working for you, you may need to install pdo_mysql extension into your php library.

Thursday, December 1, 2022
3

The problem is that my computer had another version of PHP and I was not using the XAMPP PHP, sugin XAMPP PHP solved the problem.

Monday, November 21, 2022
3

Make sure to get() the subpages as IlluminateSupportCollection and mapWithKeys() to reformat the results. Use toArray() to provide the format Nova assumes:

private function selectOptions(): array
{
    $subpages = DB::table('subpages')->get();
    return $subpages->mapWithKeys(function ($subpage) {
        return [$subpage->slug => $subpage->slug];
    })->toArray();
}

This is how the returned result should look like:

[
    'my-article-1' => 'my-article-1',
    'my-article-2' => 'my-article-2',
    'my-article-3' => 'my-article-3',
]
Thursday, September 1, 2022
 
talha_q
 
3

Decode to array and array_combine with the new keys.
Then loop the 'agent' and replace the keys again with array_combine.

$arr = json_decode($json, true);
$mainkeys = ["url", "secret_token", "agent"];
$subkeys = ["id", "quantity"];

$arr = array_combine(array_slice($mainkeys,0,count($arr)), $arr);

if(isset($arr["agent"])){
    foreach($arr["agent"] as &$val){
        $val = array_combine($subkeys, $val);
    }
}
unset($val); 

https://3v4l.org/mKePQ

array(3) {
  ["url"]=>
  string(26) "https://www.gosdoddgle.com"
  ["secret_token"]=>
  string(25) "stringstrinngstringstring"
  ["agent"]=>
  array(2) {
    [0]=>
    array(2) {
      ["id"]=>
      string(6) "sdsds1"
      ["quantity"]=>
      string(6) "sdsds1"
    }
    [1]=>
    &array(2) {
      ["id"]=>
      string(6) "sdsds1"
      ["quantity"]=>
      string(6) "sdsds1"
    }
  }
}
Tuesday, August 23, 2022
5

You can use

sudo apt-get install php7-mysql

or

sudo apt-get install php5-mysql

or

sudo apt-get install php-mysql

This worked for me.

Sunday, October 23, 2022
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :