Learn how to use eloquent without laravel

Eloquent… without Laravel!

Our journey is close to the end, hero. You learned everything about Eloquent, starting from the very basics and going through models, relationships, and other topics. You probably started to like it and think about implementing it in your next project.

In fact, creating an application without a single SQL query is tempting. Maybe you also showed it to your boss and convinced him/her to use it in your next production project.

I am so proud of you, hero!

However, there is a little problem. Yeah, the next project isn’t so new. It already exists, and, despite everything, it doesn’t use Laravel! You start to shiver. This is so sad because you passed the last week studying this new ORM, a really cool one, and then moving forward.

Ok, stop complaining! There is always a solution! You are a developer! Also, the solution is not so hard to find. If you want, you can use Eloquent without Laravel. Yes, seriously!

Actually, Laravel is not a monolithic framework. It is made up of several, separate parts, which are combined together to build something greater. However, nothing prevents you from using only selected packages in another application.

A really cool idea!

So, what are we going to see in this article?

First of all, we will explore the structure of the database package and see what is inside it. Then, you will learn how to install the illuminate/database package separately for your project and how to configure it for the first use.

Then, you will encounter some examples. First of all, we will look at the Eloquent ORM. You will learn how to define models and use them.

Having done this, as a little extra, I will show you how to use the Query Builder (remember that the “illuminate/database” package isn’t just Eloquent). Maybe you would also enjoy the Schema Builder class. I will cover it, don’t worry!

À la charge!

We will cover the following:

Exploring the directory structure
Installing and configuring the database package
Using the ORM
Using the Query and Schema Builders
Summary

About the author

Deven Rathore

I'm Deven Rathore, a multidisciplinary & self-taught designer with 3 years of experience. I'm passionate about technology, music, coffee, traveling and everything visually stimulating. Constantly learning and experiencing new things.

Pin It on Pinterest

Shares