protected function execute(array $arguments) { if (isset($arguments[0])) { if (strlen($arguments[0]) > 140) { throw new InvalidArgumentException('String too long'); } global $config; // dir $qr_dir = 'temp/qr/' . date('Y/m/d'); $qr_abs_dir = public_path() . '/' . $qr_dir; if (!Filesystem::isDirectory($qr_dir)) { Filesystem::makeDirectory($qr_dir, 0755, true); } $qr_file_name = md5('qr-code' . $arguments[0]) . '.png'; $qr_path = $qr_abs_dir . '/' . $qr_file_name; // QR $qrCode = new \Endroid\QrCode\QrCode(); $qrCode->setText($arguments[0])->setSize(300)->setPadding(10)->setErrorCorrection('high')->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0))->save($qr_path); return $config->application->domain . '/' . $qr_dir . '/' . $qr_file_name; } throw new InvalidArgumentException('strings invalid'); }