Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 4, 2021 06:37 pm GMT

Using Laravel for E-Commerce: Tutorial & Live Demo

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

But I have to admit, Ive never had the chance to explore it fully.

Today is the day I jump into PHP. However, Ill begin my journey with the darling framework that is Laravel (Ive heard it makes it easy to build secure, scalable full-stack projects from the start!).

Jumping in PHP

More especially, Ill try to build a Laravel-powered e-commerce web app.

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

Heres what the tutorial will cover:

  • Project Setup with Sail
  • Basic product listing generation, migration, and seeding
  • Using advanced models for product options
  • Front-end wiring
  • Integrating Snipcart

Time to put my PHP skills to test!

Laravel & e-commerce: quick context

Laravel is an open-source PHP web framework used to build sites & web apps.

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

With Laravel, you can leverage ComposerComposer to manage dependencies & packages. Many useful packages allow you to fast-track your Laravel development. Think stuff like debugging, authentication, API interactions, etc. Sites like Packagist & Packalyst are great resources to find helpful Laravel packages.

Since September 2020, Laravel 8 is publicly available. It introduces features such as Laravel Jetstream, model 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 to set up e-commerce functionalities on your Laravel app quickly.

Heres a curated list of the most popular ones:

  • Bagisto Code-driven & multi-featured Laravel package for e-commerce. Free & open-source.
  • Aimeos A Laravel e-commerce package and online shop solution. Free & open-source.
  • AvoRed A modular and customizable PHP shopping cart. Free & open-source.
  • Vanilo This ones actually an e-commerce framework (like Magento or Prestashop) for Laravel.
  • GetCandy An headless Laravel e-commerce API. Free & open-source.

So, where does that lead us?

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

  1. Pick a Laravel-powered CMS and add custom e-commerce to it.
  2. Use e-commerce packages built to extend your app.
  3. Build your own e-commerce application from the ground up.

First one? Fast & easy. Thats what we did for the first version of this post, using PyroCMS and then integrating Snipcart as the custom shopping cart.

Second one? Interesting. We might do it in another post at some point!

Third one? Close to what we're doing here. But building the whole application from the ground up, including e-commerce capabilities, would be highly time-consuming.

Instead, Ill show you how you can build a store from scratch using pure Laravel and then adding Snipcart to enable e-commerce and shopping cart customization.

All these options have in common the benefits youll win overusing a full-on e-commerce CMShigh scalability, easy customization, detached e-commerce functionalities, etc.

I'm thrilled to be operating inside a Laravel project for this demo. Unlike many of our Jamstack/static site tuts, it'll be super easy to handle any backend logic for our store.

Tutorial: building an e-commerce website with Laravel

Laravel E-Commerce Website With Snipcart

Prerequisites

I assume you already have a working installation of PHP and Composer running. If not, you can install them here and here.

For this tutorial, we will use Sail.

Introduced with Laravel 8, it is a light-weight command-line interface for interacting with Laravels default Docker development environment that will streamline our development environment and database setup. Sail will allow us to quickly setup a development environment and 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 app 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.

Read the full post here


Original Link: https://dev.to/pierreguillaumelaurin/using-laravel-for-e-commerce-tutorial-live-demo-18j9

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To