stacker's avatar

Is Laravel a good choice for e-commerce website?

I'm learning Laravel now because I thought it would be better to build an e-commerce site with it rather than PHP alone.

But is the Laravel stack in general (Laravel(PHP), MySQL, Apache) good choice for e-commerce? Or I should go with another option?

Any cons and pros? and tips from you guys about the site itself? Important tip for production, things I should note for the future etc..

0 likes
7 replies
bugsysha's avatar

I usually use Nginx instead of Apache. Also I would advise to use Laravel Forge and maybe even Laravel Octane for insane performance.

Yes, Laravel is great for eComm.

1 like
martinbean's avatar

@stacker Laravel is a web application framework. It’s perfectly suitable for building an e-commerce site.

My previous role was working for an e-commerce vendor that used Laravel to power thousands of e-commerce site, processing tens of millions of pounds a year in revenue.

1 like
jlrdw's avatar

Php is an excellent language for eCommerce, laravel being a php framework makes it an excellent choice for eCommerce.

Also any kind of business app you can think of.

1 like
stacker's avatar

Thank you guys. And should I use eloquent or query builder? I saw that eloquent has performance drop, but I am not sure how it shows in real life usage, or if it's really going to be noticed?

martinbean's avatar
Level 80

@stacker The benefits of using Eloquent models (relations, scopes, etc) far outweigh building queries by hand using the DB facade. Using models is also more expressive, and you can add business logic methods to model classes. You can’t do that if you‘re just doing DB::table calls all over your app.

The misnomer of Eloquent being “less performant” than using the raw query builders only becomes apparent if you’re dealing with thousands of rows in one operation. Of course hydrating row data into classes will be slower than just returning the raw row objects themselves, but you should be limiting your queries to only fetch the rows you need at that time (i.e. via pagination), so at that scale (fetching dozens of rows rather than thousands), the difference in performance is not noticeable and will be microseconds in difference.

That being said, Laravel is not a snowflake. All good practices still apply when using Laravel. If there’s data you’re fetching often but changes infrequently, then you can cache it so you’re not constantly querying your database for the same data over and over.

3 likes
jlrdw's avatar

Use eloquent for your related data if you want to. Remember Laravel is very flexible you pretty well much can do things many different ways.

Also set up your needed indexes just watch for efficiency in your queries.

I would suggest get started and start learning what to do.

2 likes

Please or to participate in this conversation.