Skip to content

Instantly share code, notes, and snippets.

@5000164
Last active August 29, 2015 14:16
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 5000164/a933cb3f485c9a60a1a0 to your computer and use it in GitHub Desktop.
Save 5000164/a933cb3f485c9a60a1a0 to your computer and use it in GitHub Desktop.
FuelPHP で Debug::dump() と Log::debug() を簡単に使えるようにする
<?php
if (!(function_exists('d'))) {
function d(...$targets)
{
if (Fuel::$env !== Fuel::PRODUCTION) {
$i = 0;
$name_prefix = 'args_';
$dump = array();
$eval_dump = '';
foreach ($targets as $target) {
$variable_name = $name_prefix . $i;
$dump[$variable_name] = $target;
$eval_dump .= '$dump[\'' . $variable_name . '\'], ';
$i++;
}
$eval_dump = substr($eval_dump, 0, -2);
$eval_dump = 'Debug::dump(' . $eval_dump . ');';
eval($eval_dump);
}
}
}
if (!(function_exists('l'))) {
function l(...$targets)
{
if (Fuel::$env !== Fuel::PRODUCTION) {
foreach ($targets as $target) {
Log::debug(print_r($target, true));
}
}
}
}
NYSL Version 0.9982
----------------------------------------
A. 本ソフトウェアは Everyone'sWare です。このソフトを手にした一人一人が、
ご自分の作ったものを扱うのと同じように、自由に利用することが出来ます。
A-1. フリーウェアです。作者からは使用料等を要求しません。
A-2. 有料無料や媒体の如何を問わず、自由に転載・再配布できます。
A-3. いかなる種類の 改変・他プログラムでの利用 を行っても構いません。
A-4. 変更したものや部分的に使用したものは、あなたのものになります。
公開する場合は、あなたの名前の下で行って下さい。
B. このソフトを利用することによって生じた損害等について、作者は
責任を負わないものとします。各自の責任においてご利用下さい。
C. 著作者人格権は 菅原 浩 に帰属します。著作権は放棄します。
D. 以上の3項は、ソース・実行バイナリの双方に適用されます。
NYSL Version 0.9982 (en) (Unofficial)
----------------------------------------
A. This software is "Everyone'sWare". It means:
Anybody who has this software can use it as if he/she is
the author.
A-1. Freeware. No fee is required.
A-2. You can freely redistribute this software.
A-3. You can freely modify this software. And the source
may be used in any software with no limitation.
A-4. When you release a modified version to public, you
must publish it with your name.
B. The author is not responsible for any kind of damages or loss
while using or misusing this software, which is distributed
"AS IS". No warranty of any kind is expressed or implied.
You use AT YOUR OWN RISK.
C. Copyrighted to Hiroshi Sugawara.
D. Above three clauses are applied both to source and binary
form of this software.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment