3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Laravel Illuminate\Foundation\Inspiringを読む

Last updated at Posted at 2025-12-03

はじめに

Fusic Advent Calendar 2025 3日目です!
昨日は、 @TsuMakotoテーブル要素をturbo-frameで部分更新したいでした

今回は、Laravelのベースコードを読んで思わず笑ったので、それについての記事を書きます。
具体的には、Laravelのroutes/console.phpにデフォルトで定義されている、artisan inspireのあたりに関してです。

artisan inspireとは、コマンド実行するとランダムにセンテンスを出力してくれるやつです。

$ sail artisan inspire

  " The best way to take care of the future is to take care of the present moment. "
  — Thich Nhat Hanh

いいセンテンスですね!

まず routes/console.php を読む

Laravel ベースコードではないですが、inspire のAritsanコマンドの定義を見ていきましょう。

static の Inspiring::quote() を Artisan$this->comment()で出力するようにしています。
さらに、->purpose()でArtisanコマンドの補足が定義されていますね。

Artisanコマンドは、$this->comment()などの出力方式やプログレスバーなど、かなり機能が充実しているので、是非ドキュメントを読んでみてください。

Illuminate\Foundation\Inspiring を読む

Illuminate\Foundation\Inspiring はこちら!

8行目に謎のドラゴンがいてめちゃくちゃ笑いました。(これを共有したかっただけ
またアルプス山脈のユングフラウヨッホから、TaylorとDayleがコミットしたよのコメントもあり、遊び心満載です。

実際の処理としては、staticで定義されているquotes()を参照して、返ってきたコレクションをrandom()で取ってからフォーマットして返してます。
シンプルですね。

おわりに

これだけです。
みなさんも、安直にベースコードを読んでいきましょう!

そのままvendor以下を読んでもいいですし、Slackなどで共有するときはlaravel/framework のリンクで共有すると見やすくて個人的に好きです。

Laravelインストール直後のコードは、laravel/laravel を見ると良きです。

では、皆さんも楽しいLaravelライフを!

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?