PDO无效的数据源名称

I'm getting 'invalid data source name' when trying to concatenate the array in config.php. It works fine if I hardcode it what am I doing wrong here?

Thanks

config.php

<?php

return [
    'database' => [
        'host' => 'mysql:host=127.0.0.1',
        'database' => 'pdo_database',
        'username' => 'root',
        'password' => '',
        'options' => [
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
        ]
    ]
];

connection.php

<?php

$config = require('config.php');
$database = $config['database'];

class Connection {
    public function make() {
        try {
            return new PDO(
                $database['host'].';dbname='.$database['database'],
                $database['username'],
                $database['password'],
                $database['options']
            );
        } catch(PDOException $e) {
            die($e->getMessage());
        }
    }
}

The problem is that the make() method can't simply access global variables. If you pass the $database configuration into the make() method...

public function make($database) {

This passes the configuration needed to create a database connection for this set of parameters.

Depending on how your using this class, you could change it to a static method

public static function make($database) {

and then use it like this...

$connection = Connection::make($database);