Are there alternative methods to efficiently handle DB adapter initialization and access in ZendFramework?

When working with ZendFramework, a common issue is efficiently handling DB adapter initialization and access. One way to solve this is by creating a separate class or factory method to handle the initialization of the DB adapter and provide a centralized point for accessing it throughout the application.

class DbAdapterFactory
{
    public static function createAdapter()
    {
        $config = [
            'driver'   => 'Pdo',
            'dsn'      => 'mysql:dbname=dbname;host=localhost',
            'username' => 'username',
            'password' => 'password',
            'options'  => [
                PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
            ]
        ];

        $adapter = new Zend\Db\Adapter\Adapter($config);
        
        return $adapter;
    }
}

// To use the DB adapter in your application
$dbAdapter = DbAdapterFactory::createAdapter();