My Journey as a Laravel Intern
Tammy Alemu
Posted on August 6, 2024
By Tammy Alemu
Hi, I’m Tammy Alemu. Let me take you through my exciting journey as a Laravel intern. I aimed to gain industry experience, write readable code, and understand the framework deeply. Here’s how it all went down, with the challenges I faced and the solutions I found along the way.
During my internship, I had three primary goals:
Industry Experience: Gain practical experience in a professional environment.
Readable Code: Write clean, maintainable, and readable code.
Framework Understanding: Develop a deep understanding of the Laravel framework.
Development Environment
My journey began with setting up the development environment. Before this internship, I interacted with the backend using a frontend architecture, either through Blade views or JavaScript bundled with Vite. So, I didn’t really see the necessity to set up CORS and all that. Then, I got introduced to Postman — wow, what a game-changer!
Postman
Postman helped me set and edit HTTP requests, pass parameters and values, and manage authentication and bearer tokens. This broadened my understanding of the backend’s structure and how it works. Seeing data in its raw form and manipulating it directly was eye-opening. I realized that the seemingly complex backend operations were more straightforward than I initially thought.
Composer
Composer was another essential tool. I used it to install packages and adhered strictly to PHP PSR-4 formatting standards. When I say strictly, I mean it! Haha. I ran into errors when I didn’t follow the standards, like generating documentation and realizing I had errors in namespaces due to extra spaces or incorrect naming conventions for models and tables.
Project Setup
Setting up the project involved several key steps:
Repository Management
Cloning repositories and setting up my environment was quite overwhelming at first — haha, what a ride! I was introduced to scribe:generate, a package that generates documentation. Initially, I was like, “What?!” Running specific class seeders was another challenge. I didn’t understand their purpose compared to normal seeders until I realized php artisan db:seed --class=...Seeder
runs a specific seeder class directly, useful for seeding specific tables or data sets individually.
Model and Data Handling
I highlighted the parameters needed when adding new attributes to models and specified data types. Familiarizing myself with data serialization and transformation to format responses was crucial. I also learned to use includes and default includes for formatting specific data and parsed includes to add data to responses.
Eager Loading
Eager loading was one of the beautiful things I learned. Instead of lazy loading, where a new SQL query executes within a loop, eager loading performs a single query to load all necessary data. The with helper became vital for efficient database querying, this made me look into beautiful helpers available in Laravel, what a difference it made!
Query Scopes and Builders
I used query scopes available to the controller to fetch data before transforming them. Query builders also became my go-to for streamlined data retrieval.
Controllers
Controllers handle basic logic for various request types (GET, POST, UPDATE). I learned to write endpoints and clearly comment for Scribe documentation. Using actions to extract reusable code into different controllers ensured a clean code structure. Implementing try-catch methods when working with the database was another valuable lesson.
Views
Although not used extensively, views were mainly used to format mail responses.
API Development
I learned to design and implement APIs following RESTful principles and tested them using Laravel’s built-in logging tools and Postman.
This knowledge further spawns me to building and working with Laravel socialite, integrating google auth for sign in and the use of Laravel sanctum, live on my GitHub profile.
Challenges and Solutions
Challenges
Understanding the codebase was initially tough, especially since there were no collection routes available in Postman. I had to build them and understand the structure, which sometimes required extra parameters and slowed my development process.
My shallow fundamental knowledge of PHP also affected my progress, leading to extra time spent on tasks.
Solutions
To overcome these challenges, I focused on learning the fundamentals and practiced by working on a separate branch aside from my assigned tasks. I took a deep dive into understanding PHP, sourcing resources like “Programming with GIO,” “PHP the Right Way,” and Laracasts — highly recommend them!
It’s okay not to have the syntax memorized. Haha, for cases like this, I always referred to documentation. Reading docs broadens your understanding of a particular topic.
Overall, my experience working with the team has been superb. Besides being a paid position, they offered help with understanding and building apps. The team I work with explains the tasks intended to achieve and gives swift responses when attending to challenges I face.
Posted on August 6, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.