A note of what I stumbled upon and noticed in catching up with Laravel from Rails

Introduction

I'm a web engineer in my first year of work. This article is a memorandum and memorized output about Laravel.

This article will be serialized slowly. There are three reference books, and I am currently studying the second one.

If anyone has started learning Laravel, I would be grateful if you could take a look with them. If you have any suggestions, please do so.

** (I used Ruby / Rails originally, so if there is the same person, I hope it will be helpful ...) **

This time,

--Regarding the directory structure --Import class by name class and use --Request class --Layout creation and inheritance --Additional word memo

I have a note about it.

Regarding directory structure

I have summarized the points that I thought were important in the directory structure that I tend to forget.

Importing classes by namespace and use

"Namespace" is difficult Japanese, but ** where are you? I think it means to show information such as **. Regarding use, it is a description required to import another class. Is it something like Rails require ...?

sample.php


namespace App;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

Request class

The information sent from the client to the server is the request, and the reverse is the response. It can be used with use Illuminate \ Http \ controllers;.

sample.php


use Illminate\Http\Request;

function test(Request $request) {
 $request->url();
}

The methods that can be used are here. (official)

Layout creation and inheritance

When using the blade template, you can use the functions @section and @yield. The part enclosed by @ section- @ sectionend is output to @yield

I felt that I could do something similar to vue's components. From the book, this article was helpful.

Words etc tips notes

--Here document Used when writing long PHP texts. Something like << EOF. --Single action controller If you create a controller with only one action, you can call it with just the controller name without specifying the action from route. --Of course, you can pass variables to view from the controller like Rails. Can also be named

sample.php


function index(Request $request) {
 return view("hello.index", ["msg" => $request->msg]);
}

It can be called with a variable called $ msg. --HTML escape processing {{!! HTML tags written in this are escaped and output as text !!}}

Helpful articles

--Regarding dependencies https://qiita.com/harunbu/items/079ea728d2c9cf4f44d5 --About closures https://qiita.com/Yametaro/items/7a4521e23520947cc43e --General https://qiita.com/Masahiro111/items/82677e7cb2d5c1ba8386 --The file can be different, unlike the component (which was there) and section. https://qiita.com/taka_no_okapi/items/19bde6089ac1a22822d2

Next time, I'll start from around the composer ...

Recommended Posts

A note of what I stumbled upon and noticed in catching up with Laravel from Rails
[Note] What I learned in half a year from inexperienced (Java)
[Note] What I learned in half a year from inexperienced (Java) (1)
[Note] What I learned in half a year from inexperienced (Java) (3)
Note that I stumbled upon building the Rails environment
What I stumbled upon in the ActiveModel :: Serializer test
Build a bulletin board API with authentication authorization in Rails # 12 Association of user and post
I tried JAX-RS and made a note of the procedure
What I learned from studying Rails
I knew what reflection was
What I was addicted to while using rspec on rails
Rails does it automatically and it helps, but I was surprised
A note of what I stumbled upon and noticed in catching up with Laravel from Rails
What I was addicted to when implementing google authentication with rails
[Rails] What was the error message?
[Rails] What I learned from a little stumbling block when using ancestry
I was a little addicted to running old Ruby environment and old Rails
What I learned from Java monetary calculation
I didn't know what to write in Maven's scope so I looked it up
What I learned from studying Rails
I'm worried about producing with JAVA and XML, so make a note of what I'm trying to do without forgetting (display in for statement)
I built a rails environment with docker and mysql, but I got stuck
[Rails] I want to send data of different models in a form
A note of someone who stumbled when trying to create a Rails project
[Rails] What I learned from a little stumbling block when using ancestry
I stumbled upon the development and publication of my first iPhone app
I wrote a Lambda function in Java and deployed it with SAM
I tried to make a web application that searches tweets with vue-word cloud and examines the tendency of what is written in the associated profile
What I investigated in Wagby development Note 1
What I stumbled upon when installing Laravel-filemanager
Rails6 I want to make an array of values with a check box