iTranslated by AI
Learning Laravel with Osaru: Where to Find View Files! ๐

Hello everyone!
I'm Osaru ๐, and I'm currently obsessed with Blue Jeans/HANA lol.
Lately, I've been listening to my favorite songs on repeat while studying for certifications!
In the midst of that, an engineer in my company who is learning Laravel asked me this...
Osaru-san, where were the View files located in Laravel again?
So, in this article, I'm going to introduce the Laravel directory structure!
โ What is Laravel?
Laravel is a handy toolbox (framework) for building web apps with PHP.
And Laravel operates using a mechanism called "MVC."
What is MVC?
I introduce it in the article below, so please take a look if you're interested ๐
[Too late to ask?] What is "MVC Architecture"?
https://zenn.dev/osaru07m/articles/2af42e02027b86
๐ Let's look at the big picture!
Let's try creating a project called sample.
Let's take a rough look at the directory structure immediately after creating it with the following command.
laravel new sample
In this case, sample/ is the root directory of the Laravel project.
sample/
โโโ app/
โโโ bootstrap/
โโโ config/
โโโ database/
โโโ public/
โโโ resources/
โโโ routes/
โโโ storage/
โโโ tests/
โโโ vendor/
At first, you might think "There are too many directories!", but don't worry!
The places you basically use often are limited, and specifically for frontend tasks, the one you'll touch is resources/views.
๐ผ Where are the View Files?
The "View files" mentioned in the question earlier are located in resources/views/!
This is where you place Blade template files (.blade.php).
For example, welcome.blade.php is included by default, and it's used to display the top page.
โ๏ธ Let's Try Using It Easily
Create a View File
This time, we will create a Blade template file called hello!
And, I have written the following code.
<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
</head>
<body>
<h1>ใใใซใกใฏใLaravel๏ผ</h1>
</body>
</html>
Edit the Route File
Next, let's edit routes/web.php and try displaying the Blade template file we just created!
Route::get('/hello', function () {
return view('hello');
});
Now, if you access http://localhost/hello in your browser,
the hello.blade.php you just created will be displayed! ๐
๐ Quick Introduction to Other Directories
There are other directories that you will frequently touch besides View.
| Directory | Description |
|---|---|
app/ |
A place to organize application logic. As the name suggests, it's the "content of the app," so it contains controllers (responsible for receiving requests) and models (responsible for the database). |
routes/ |
Responsible for page entry points, containing files for routing settings (e.g., web.php). |
public/ |
Contains publicly accessible static files (index.php (containing logic to run Laravel), images, CSS, JS). |
config/ |
Contains configuration files for basic settings. |
database/ |
Contains all database-related files, such as migrations and seeders. |
โ If You Can Understand and Remember This Much, You're OK!
Laravel's directory structure may look cluttered at first glance, but for now, you'll be fine if you keep these three in mind: resources/views, app/, and routes/. ๐
- Page appearance:
resources/views/ - Actual processing:
app/ - Page entry points (URL assignment):
routes/
If you can get a sense of how these three are connected, developing with Laravel will become much easier ๐ก
๐ Summary
- Laravel's View files are in
resources/views/ - You can write templates with the
.blade.phpextension - By combining them with routing, you can freely add pages
Laravel may seem complex, but it's actually a very simple and convenient framework ๐
Let's become a Laravel Master together with me! lol ๐ช
Discussion