10 best laravel ecommerce packages for your online store

This is an updated version of an older post. In the first version, we experimented with a shopping cart integration with the Laravel-powered PyroCMS. I’ll bởi vì something different here, but if that first iteration sounds interesting to you, you can find the GitHub repo & live sầu demo here.

Bạn đang xem: 10 best laravel ecommerce packages for your online store

In a rush? Skip to lớn tutorial steps or live kiểm tra.

PHPhường is, in some ways, the backbone of the Internet. I mean, it is at the core of WordPress, which powers 39.9% of all the websites today. It is also used by the biggest social media; Facebook.

But I have to lớn admit, I’ve sầu never had the chance khổng lồ explore it fully.

Today is the day I jump into lớn PHP.. However, I’ll begin my journey with the darling framework that is Laravel (I’ve heard it makes it easy lớn build secure, scalable full-staông xã projects from the start!).


More especially, I’ll try to lớn build a Laravel-powered e-commerce website phầm mềm.

Hopefully, this will show you the benefits Laravel can bring lớn your next e-commerce venture.

Here’s what the tutorial will cover:

Project Setup with SailBasic product listing generation, migration, and seedingUsing advanced models for product optionsFront-over wiringIntegrating wpuonline.com

Time khổng lồ put my PHP. skills lớn test!

Laravel và e-commerce: quiông chồng context

Laravel is an open-source PHP website framework used lớn build sites & website apps.

It has a smooth learning curve, removes some quirks of building with PHPhường, and has many modern built-in libraries. Some say it"s the Ruby on Rails PHPhường equivalent.

With Laravel, you can leverage ComposerComposer khổng lồ manage dependencies và packages. Many useful packages allow you to fast-traông xã your Laravel development. Think stuff like debugging, authentication, API interactions, etc. Sites like Packagist & Packalyst are great resources khổng lồ find helpful Laravel packages.

Since September 20đôi mươi, Laravel 8 is publicly available. It introduces features such as Laravel Jetstream, mã sản phẩm factory classes, migration squashing, job batching, improved rate-limiting, dynamic Blade components, Tailwind pagination views, time testing helpers, and more.

Tools for e-commerce on Laravel?

Of course, there are existing e-commerce packages for Laravel. They can help khổng lồ mix up e-commerce functionalities on your Laravel ứng dụng quickly.

Here’s a curated menu of the most popular ones:

So, where does that lead us?

The three e-commerce options with Laravel are pretty much:

Piông xã a Laravel-powered CMS and add custom e-commerce to lớn it.Use e-commerce packages built khổng lồ extend your tiện ích.Build your own e-commerce application from the ground up.

First one? Fast & easy. That’s what we did for the first version of this post, using PyroCMS & then integrating wpuonline.com as the custom shopping cart. Link at the top of this post.

Second one? Interesting. We might vày it in another post at some point!

Third one? Cthua trận lớn what we"re doing here. But building the whole application from the ground up, including e-commerce capabilities, would be highly time-consuming.

Instead, I’ll show you how you can build a store from scratch using pure Laravel and then adding wpuonline.com to enable e-commerce & shopping cart customization.

All these options have sầu in common the benefits you’ll win overusing a full-on e-commerce CMS—high scalability, easy customization, detached e-commerce functionalities, etc.

I"m thrilled khổng lồ be operating inside a Laravel project for this test. Unlượt thích many of our Jamstack/static site tuts, it"ll be super easy to handle any backkết thúc ngắn gọn xúc tích for our store.

Xem thêm: Cách Tải Phần Mềm Chơi Cờ Vua Trên Máy Tính Laptop Miễn Phí, Tải Và Chơi Cờ Vua Trên Máy Tính

Tutorial: building an e-commerce website with Laravel



I assume you already have a working installation of PHPhường and Composer running. If not, you can install them here và here.

For this tutorial, we will use Sail.

Introduced with Laravel 8, it is a light-weight command-line interface for interacting with Laravel’s mặc định Docker development environment that will streamline our development environment & database cài đặt. Sail will allow us to lớn quickly setup a development environment và database completely isolated from our local environment.

Since Sail interacts with a Docker environment, that means you will also need Docker Desktop (a great tool for tiện ích development these days). If you prefer, of course, you could plug in a local SQL database or use Homestead from Laravel. The latter is an all-in-one vagrant image that allows you to get started quickly.

1. Create an e-commerce Laravel project

Laravel offers a simple commvà to lớn init (initiate) a project.

First, make it available by running: composer global require laravel/installerThen create the project: composer create-project laravel/laravel laravel-project.And cd laravel-project lớn go inkhổng lồ the project’s folder.

2. Create the Sail environment

Laravel Sail comes preinstalled with Laravel 8 projects.

However, if you want lớn install it lớn an existing project, run the following commands:

composer require laravel/sail --devphp artisan sail:install

Then, run ./vendor/bin/sail up lớn start our development environment, including a database and an gmail server. (wpuonline.com handles store related emails for you)

Note: I recommover that you mix a sail alias in your terminal for ./vendor/bin/sail up. If you use bash, you vì so by adding alias sail="bash vendor/bin/sail" in your .bashrc file. For the rest of this tutorial, I will use **sail** alias instead of **./vendor/bin/sail**.

3. Generating a basic hàng hóa listing

Now that we have sầu our Laravel project cài đặt, let"s add our products.

I hope you didn"t have sầu breakfast yet because today, we will be creating a premium oatmeal recipe store!

For these recipes, we will first need ingredients, which means we will need a controller and a data Model in our app. Let’s create them with the following command:php artisan make:Mã Sản Phẩm -a Ingredient

This generates a few files:

A migration, in database/migrations/date_create_ingredients_table.phpA controller, in app/Http/Controllers/IngredientController.phpA model, in app/Models/Ingredient.phpA seeder, in database/seeders/IngredientSeeder.php

In the controller, remove sầu all methods except the index one. The Controller uses Eloquent ORM khổng lồ fetch all ingredients in the database & returns them as a JSON các mục. For those who vày not know: an ORM stands for object-relational mapper and basically allows us to lớn write database queries in the code language of our choice (PHPhường, in our case). The JSON menu created by the controller that uses Eloquent ORM looks like this:

jsonSerialize()` format them as a json menu */ return response()->json(Ingredient::all()->jsonSerialize()); }}This method will take all of our ingredients in the database and return them in a JSON format.

The only missing thing for our method lớn be called from an API endpoint is linking this controller method khổng lồ a route, or, if you prefer, match the method lớn a URL. In routes/api.php, add the following line: Route::get("/ingredients", );

This maps GET requests on /api/ingredients lớn our index method on the IngredientController. Having an API will allow us khổng lồ use wpuonline.com"s JSON crawler in order to thiết lập price dynamically. If, however, you bởi not need an API, you could go a more traditional (MVC) way, and return a view instead of the json:view("ingredients.list", <"ingredients" => Ingredient::all()>);

You would then need khổng lồ build a view using Laravel"s blade templating language.

Now that our controller is ready, let"s define what an ingredient is in the migration file. I changed the up method in mine to be:

Schema::create("ingredients", function (Blueprint $table) $table->bigIncrements("id"); $table->string("name"); $table->mediumText("description")->nullable(); $table->string("category"); $table->decimal("price_per_gram", 8, 3););This mã sản phẩm defines how our database Ingredient table should look. But how can we create that database? Simple! You just have to lớn run that migration with sail artisan migrate.

That commvà will apply a migration, which basically means it will implement the required changes lớn our database (which, in this case, means creating our ingredient table, and adding the relevant columns & rows).

Our controller should now work. When fetching at YOUR_APP_PORT/api/ingredients, you should get an empty menu.

I’ve sầu added sample ingredients in a Seeder, in database/seeds/IngredientsTableSeeder.php (created by running php artisan make:seeder IngredientsTableSeeder):

class IngredientsTableSeeder extends Seeder public function run() DB::table("ingredients")->insert(< < "name" => "Quichồng Oats", "description" => "100% whole grain oats (quiông xã cooking)", "category" => "oats", "price_per_gram" => 0.007, >,/* ... many more! ... */ >); Seeders can be used either in development to have sầu kém chất lượng data lớn play with or to feed initial information in the DB. To put that data in the database, run sail artisan db:seed --class=IngredientSeeder.

You’ll then receive sầu everything as JSON when fetching /api/ingredients.

Xem thêm: Ý Nghĩa Màu Sắc Cuộc Trò Chuyện Trên Messenger Trên Facebook Cực Bắt Mắt

4. Using advanced models for custom recipes

You could stop there, & you’d have the basis for a headless sản phẩm API selling ingredients. But as we want lớn sell oatmeal recipes, we need to have sầu a way to lớn combine ingredients into lớn a custom recipe. Advanced Laravel models will allow us to vày just that.

We will add a “Recipe” controller with its mã sản phẩm. Our recipe mã sản phẩm will be composed of many ingredients, each with a quantity. We can represent this with the following schema (I promise, it’s the only times we’ll use UML):

Chuyên mục: Theme wordpress