1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<?php namespace App\Controller; use App\Controller\AppController; use QRcode; class QrCodesController extends AppController { public function creer($message) { $fileName = $this->request->session()->id().'.png'; $cakephpPath = str_replace('webroot/index.php', '', $_SERVER['SCRIPT_FILENAME']); $qrCodePath = $cakephpPath . 'webroot/img/' . $fileName; $this->request->session()->write('filename', $fileName); return QRcode::png($message, $qrCodePath); } }