/** * Get available printer drivers * @return array|string[] * @throws DevicesListingFailedException */ public function getDrivers() { try { $process = ProcessUtil::instance()->executeCommand([$this->manager->getLpinfoBinary(), '-m']); $matches = []; $driversList = []; if (!preg_match_all('/([^\\s]*) (.*)/', $process->getOutput(), $matches, PREG_SET_ORDER)) { throw new DevicesListingFailedException('Invalid "lpinfo" command output.'); } foreach ($matches as $match) { $driversList[$match[2]] = $match[1]; } return $driversList; } catch (ProcessFailedException $e) { throw new DevicesListingFailedException('The command "lpinfo" failed.', 0, $e); } }