Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Laravelのヘルパー

 Laravelのヘルパー

Laravel 5.1 のヘルパーについて

Yuya Takahashi

June 16, 2016
Tweet

More Decks by Yuya Takahashi

Other Decks in Technology

Transcript

  1. Support ͷ helpers.php <?php use Illuminate\Support\Arr; use Illuminate\Support\Str; use Illuminate\Support\Collection;

    use Illuminate\Support\Debug\Dumper; use Illuminate\Contracts\Support\Htmlable; if (! function_exists('append_config')) { /** * Assign high numeric IDs to a config item to force appending. * * @param array $array * @return array */ function append_config(array $array) { ...
  2. Foundation ͷϔϧύʔ • app($make = null, $parameters = []) •

    ίϯςφ͔ΒΠϯελϯεΛऔΓग़͠·͢ɻͳʹ΋ࢦఆ͠ͳ͍ ͱ Application Λฦ͠·͢ɻ • logger($message = null, array $context = []) • σόοά༻ͷϩάΛॻ͖ࠐΈ·͢ɻ • session($key = null, $default = null) • $keyʹ഑ྻΛ౉͢ͱอଘɺจࣈྻͳΒऔಘ͠·͢ɻ
  3. Support ͷϔϧύʔ 1 • array_except($array, $keys) • $keysʹϚονͨ͠$arrayΛআڈͯ͠ฦ͠·͢ɻ • array_only($array,

    $keys) • $keysʹϚονͨ͠$array͚ͩΛฦ͠·͢ɻ • collect($value = null) • Illuminate\Support\Colleciton Λฦ͠·͢ɻ • $valueʹ഑ྻΛ౉ͤ͹itemsͷॳظ஋ͱͯ͠ηοτͯ͘͠Ε·͢ɻ
  4. Support ͷϔϧύʔ 2 • dd() • σόοά༻ʹϑΥʔϚοτͯ͠ग़ྗ͠·͢ɻʢSAPIʹΑͬͯ੾ΓସΘΔʣ • ࣮ߦ͞ΕΔͱॲཧ͸தஅ͞Ε·͢ɻ •

    str_contains($haystack, $needles) • $needles͕$haystackʹؚ·Ε͍ͯΕ͹trueɺٯͳΒfalseΛฦ͠·͢ɻ • str_random($length = 16) • ϥϯμϜͳӳ਺ࣈจࣈྻΛऔಘ͠·͢ɻ • ಺෦Ͱ͸PHP7͔Β௥Ճ͞Εͨ random_bytes() ͕࢖༻͞Ε͍ͯ·͢ɻ