1
4

More than 3 years have passed since last update.

【Laravel】外部blade.phpファイルの読み込み

Posted at

はじめに

知識を整理するための個人的な備忘録です。

今回は、header.blade.phpファイルを複数のページで使い回したいと思います。

方法

1.resources/viewsの中にフォルダを作成

フォルダ名はsharedとしましたが、任意のフォルダ名で問題ないです。

2.sharedフォルダの中にheader.blade.phpファイルを作成

header.blade.phpファイルですが、読み込み先のファイルに<html></html>タグや<body></body>タグが既に記載されているので、これらを書く必要はありません。

3.読み込む

header.blade.phpを読み込みたいファイルの中に以下のコードを書きます。

@include('shared.header')

参考

【Laravel】外部PHPファイルの呼び出し方法【5分で完了】

1
4
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
1
4