Skip to content

Instantly share code, notes, and snippets.

@tai-sho
Created July 11, 2017 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tai-sho/b2fa936ca7749e93fc99fa4f38a341dd to your computer and use it in GitHub Desktop.
Save tai-sho/b2fa936ca7749e93fc99fa4f38a341dd to your computer and use it in GitHub Desktop.
QRコードを出力するHelper #cakephp
<?php
/**
* QRコード出力
*/
class QRHelper extends AppHelper {
/**
* QRコードを扱うAPIのURL
* @var string
*/
protected $_apiUrl = ' https://api.qrserver.com/v1/create-qr-code/';
/**
* QRコードのURLを出力します。
* @param string $data QRコードに埋め込むデータ
* @param array $options 設定
* @return string
*/
public function create($data, array $options = array()) {
$default = array(
'size' => array(100, 100),
'bgcolor' => null,
'color' => null,
'format' => 'png'
);
$options = Hash::merge($default, $options);
$options['data'] = $data;
$options['size'] = implode('x', $options['size']);
return $this->_apiUrl. Router::queryString($options, array(), true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment