QrCodesController.php
716 Bytes
<?php
namespace App\Controller;
use App\Controller\AppController;
use QRcode;
class QrCodesController extends AppController
{
public function creer($message = null) {
$fileName = $this->request->session()->id().'.png';
$cakephpPath = str_replace('webroot/index.php', '', $_SERVER['SCRIPT_FILENAME']);
$qrCodePath = $cakephpPath . 'webroot/img/qrcodes/' . $fileName;
$this->request->session()->write('filename', $fileName);
$this->request->session()->write('qrCodePath', $qrCodePath);
if($message == null) {
return \PHPQRCode\QRcode::png($this->request->session()->read('qrUrl'), $qrCodePath);
} else {
return \PHPQRCode\QRcode::png($message, $qrCodePath);
}
}
}