# Bagisto Laravel E-commerce

> Modern Laravel-based e-commerce with multi-warehouse and marketplace support.

- Category: E-Commerce & Business
- Difficulty: intermediate
- Components: bagisto, mysql, redis, elasticsearch, nginx
- Tags: bagisto, laravel, ecommerce, php, marketplace
- Source: https://docker.recipes/ecommerce/bagisto-ecommerce

## Overview

Bagisto is a modern, Laravel-based e-commerce platform that provides multi-warehouse management, marketplace functionality, and extensive customization capabilities for online retailers. Built with a headless architecture approach, Bagisto separates the frontend presentation layer from the backend business logic, making it ideal for businesses requiring custom storefronts or multi-channel selling strategies. This implementation combines Bagisto with MySQL for transactional data storage, Redis for session management and caching, Elasticsearch for product search and analytics, and NGINX as a high-performance web server and reverse proxy. The stack creates a robust e-commerce environment capable of handling complex inventory management across multiple warehouses while providing fast search capabilities and efficient caching for improved customer experience. This configuration is particularly valuable for medium to large-scale online retailers, marketplace operators, and businesses with complex inventory requirements who need a scalable platform that can grow with their operations while maintaining the flexibility to customize both frontend experiences and backend workflows.

## Features

- Multi-warehouse inventory management with real-time stock tracking across locations
- Built-in marketplace functionality supporting multiple vendors and commission structures
- Laravel framework foundation with Eloquent ORM for rapid custom development
- Elasticsearch-powered product search with faceted filtering and real-time indexing
- Redis-based session storage and application caching for improved performance
- Multi-currency and multi-language support for international e-commerce operations
- RESTful API architecture enabling headless commerce implementations
- MySQL 8.0 with InnoDB storage engine providing ACID compliance for transactional integrity

## Use cases

- Multi-vendor marketplaces requiring vendor management and commission tracking
- Retailers with multiple warehouse locations needing unified inventory management
- B2B e-commerce platforms requiring custom pricing and bulk ordering features
- International retailers needing multi-currency and multi-language capabilities
- Businesses requiring headless commerce architecture for custom frontend applications
- Growing online stores needing scalable search functionality for large product catalogs
- Custom e-commerce solutions requiring extensive Laravel-based backend modifications

## Prerequisites

- Minimum 4GB RAM (2GB for Elasticsearch, 1GB for MySQL, 512MB for Redis, 512MB for application)
- Docker Engine 20.10+ and Docker Compose v2 for modern compose file support
- Available ports 80 for web access and 9200 for Elasticsearch (if external access needed)
- Basic understanding of Laravel framework and PHP for customization and troubleshooting
- Familiarity with MySQL database administration for backup and maintenance procedures
- Understanding of Elasticsearch concepts for search optimization and index management

## docker-compose.yml

```yaml
services:
  mysql:
    image: mysql:8.0
    environment:
      - MYSQL_DATABASE=bagisto
      - MYSQL_USER=bagisto
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - bagisto_net

  redis:
    image: redis:7-alpine
    volumes:
      - redis_data:/data
    networks:
      - bagisto_net

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
    environment:
      - discovery.type=single-node
      - xpack.security.enabled=false
    volumes:
      - es_data:/usr/share/elasticsearch/data
    networks:
      - bagisto_net

  bagisto:
    image: bagisto/bagisto:latest
    environment:
      - APP_URL=http://localhost
      - DB_HOST=mysql
      - DB_DATABASE=bagisto
      - DB_USERNAME=bagisto
      - DB_PASSWORD=${MYSQL_PASSWORD}
      - REDIS_HOST=redis
      - ELASTICSEARCH_HOST=elasticsearch
    volumes:
      - bagisto_data:/var/www/html
    depends_on:
      - mysql
      - redis
      - elasticsearch
    networks:
      - bagisto_net

  nginx:
    image: nginx:alpine
    ports:
      - "80:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - bagisto_data:/var/www/html:ro
    depends_on:
      - bagisto
    networks:
      - bagisto_net

volumes:
  mysql_data:
  redis_data:
  es_data:
  bagisto_data:

networks:
  bagisto_net:
```

## .env

```bash
# Bagisto
MYSQL_PASSWORD=secure_mysql_password
MYSQL_ROOT_PASSWORD=secure_root_password

# Shop at http://localhost
# Admin at http://localhost/admin
```

## Usage notes

- Shop at http://localhost
- Admin at http://localhost/admin
- Built on Laravel framework
- Multi-warehouse support
- Marketplace module available

## Troubleshooting

- Elasticsearch container fails with 'max virtual memory areas vm.max_map_count too low': Increase vm.max_map_count with 'sudo sysctl -w vm.max_map_count=262144'
- Bagisto shows 'SQLSTATE[HY000] [2002] Connection refused' error: Ensure MySQL container is fully started before Bagisto container attempts connection
- Product search returns no results despite having products: Check Elasticsearch indexing status in Bagisto admin and manually trigger reindexing if necessary
- Redis connection timeout errors in application logs: Verify Redis container health and increase Redis timeout settings in Bagisto configuration
- NGINX shows 502 Bad Gateway error: Check that Bagisto PHP-FPM process is running and accessible on the expected port within the container
- MySQL container exits with 'disk space' error: Clean up old MySQL binary logs or increase available disk space for mysql_data volume

