[Laravel/Lumen] A story about "efficiency" told by a novice & veteran engineer [Beyond study session #30]
Hello!
This is Fukui from the System Development Department!
It may seem out of the blue, but I think it is a mission for developers to write programs that are ``faster, less burdensome, and more readable,'' and this is an important theme.
So, we thought, ``Let's know what to do to make development more efficient!'' So we focused on the ``Laravel, Lumen'' framework, which is often used in our PHP development, and created a project for Xtrans Co., Ltd. With our cooperation, we jointly held a study session!
Stories about “efficiency” told by budding and veteran engineers
This time, the main theme was [Stories about "efficiency" told by budding and veteran engineers], and we had the following three great speakers talk about it!
1. “ Let's make database access more efficient with Eloquent! ” Masari Nishihara, Beyond Inc.
2. “ Best practices that you can understand only by making full use of the collection function ” Yoichi Bandyo, Beyond Inc.
3. “ In-house apps using Lumen The story of how I made it ” Mr. Yukichi Nanko of Xtrans Co., Ltd.
*Videos of each speaker's presentation can be viewed on Youtube at the link in the title.
Session 1: “Use Eloquent to streamline DB access!”
First of all, we started with Nishihara from Beyond taking the stage.
Like Nishihara, I've been an engineer for six months now, and the introductory part, "It's not enough to just move...!!" really stuck with me...!
After giving an overview of Laravel and MVC with a focus on reducing load and considering processing speed, we will move on to a discussion on efficient handling of models.
This time, he used a demonstration to explain in an easy-to-understand way how to efficiently retrieve records with relationships using Eloquent's "with function."
After explaining the difference in execution queries based on the number of DB accesses, there was a comparison verification of ``processing speed'' and ``memory usage'' with ``without using the with function'', and the superiority of the with function was verified. was obvious at a glance.
I often use the with function in my work, but I have come to realize once again how useful it is...!
In addition, in the second half, with the theme of ``Is there a way to reduce memory usage other than the with function?'', they also tried using the chunk function and cursor function, which was very interesting!
Click here for the video of the presentation
"Let's streamline DB access using Eloquent!"
Session 2: “Best practices that can only be understood by fully using the collection function”
In the second session, Bandai from Beyond will also be on stage.
I feel the weight of the words "I've been using PHP for 15 years" at the beginning...!
This time, we were given an overview of Collection, its advantages and disadvantages, and how to use it.
I myself sometimes use Collections when manipulating arrays, but I still have a lot to learn about them, so I found a lot of useful content and points that I would like to refer to.
In the first half, he explained the ``difference between Collection and foreach'' using the case of ``performing multiple processes on an array'' as an example, and the content was very easy to understand and easy to understand.
Also, with the theme of ``Collections can be used in tests,'' he introduced an example of how to use the Collection method in a unit test, which I personally thought was something I wanted to keep in mind!
In addition, there were many other problems using Collection, such as ``unique combinations made using three numbers from 1 to 10'' and ``Students' test deviation values'', so be sure to check out the videos. Please take a look at the explanation inside!
Click here for the video of the presentation
"Best practices that can be understood only by using the collection function to the fullest"
Session 3: “A story about creating an in-house app using Lumen”
In the third and final session, Mr. Nanko from Extrans Co., Ltd. took the stage!
The theme of the talk was "A story about creating an in-house application using Lumen," and the first thing that caught my attention was Nankou's "love for Gophers"...! (Please watch the presentation video for details!)
As for the content of his presentation, Mr. Nanko first explained why he started using Lumen, gave an overview of Lumen, and then introduced the ``approval request email delivery app'' that he had actually created.
In the first half, Mr. Nankou talked about himself before and after using Lumen, and talked about how convenient frameworks are, which was very impressive!
After that, we will use code examples to explain how to write Lumen's routing, controller (and model), and validation processes, and in the second half, the topic will shift to ``Differences between Lumen and Laravel.''
He explained in more detail the differences in how to write the artisan commands that cannot be used in Lumen, loading Facade/Eloquent, and acquiring environment variables.
In addition, at the end, he summarizes the advantages and disadvantages of Lumen, the usability and characteristics of the framework, and the differences from Laravel, so you can watch a more specific talk from the presentation video!
Click here for the video of the presentation
"A story about creating an internal app using Lumen"
summary
What did you think?
Through sessions 1 to 3, we received a broad and easy-to-understand explanation of how to use and write Laravel (Lumen) efficiently, useful functions, and the differences between Laravel and Lumen. I think the content will be useful to everyone! (For me personally, it was a very rewarding study session...!)
Beyond will continue to hold study sessions on infrastructure and development, so please feel free to join us for the next study session using connpass " or " Doorkeeper
*If you register as a member of each community, you can immediately check when study sessions are being held.
・Beyond study session | connpass
・Beyond study session | Doorkeeper
lastly
I have opened the system development service site "SEKARAKU Lab" to which I belong.
Beyond is a one-stop service for everything from server design and construction to operation, so if you have any trouble with server-side development, please feel free to contact us.
SEKARAKU Lab: [https://sekarakulab.beyondjapan.com/](https://sekarakulab.beyondjapan.com/)
Thank you for reading until the end!