PickBazar Documentation
WelcomeHow It WorksGetting StartedFeaturesAvailable ScriptsCustomizationStyles and AssetsUtilities
Back-End Integration
Deployment
Update
SEO and Analytics
API
Laravel APIIntroductionGetting StartedInstallationConfigurationConsole CommandsDevelopmentREST APIGraphQL APIExtending The FunctionalityDeployment
Social LoginOTP (Mobile Number Verification)TranslationMultiVendorNew PageExport ImportFAQSupportVersionsReadme

Introduction

Pickbazar is a laravel multi api package for ecommerce. This package is for building dynamic ecommerce site using pickbazar package with graphql/rest.

Getting Started

For getting started with the template you have to follow the below procedure. For quick guide you can check below videos for installation.

Installation Windows

Prerequisites

  • PHP 7.4

  • Composer

  • Xamp/Wamp/Lamp for any such application for apache, nginx, mysql

  • PHP plugins you must need

    • simplexml
    • PHP's dom extension
    • mbstring
    • GD Library

Resources you might need

  1. https://laravel.com/docs/8.x
  2. https://lighthouse-php.com/5/getting-started/installation.html
  3. https://github.com/spatie/laravel-medialibrary
  4. https://github.com/andersao/l5-repository
  5. https://spatie.be/docs/laravel-permission/v3/introduction

Packages we have used

"mll-lab/graphql-php-scalars": "3.1.0",
"nuwave/lighthouse": "^4.18.0",
"laravel/legacy-factories": "^1",
"cviebrock/eloquent-sluggable": "^8.0",
"laravel/sanctum": "^2.7",
"mll-lab/laravel-graphql-playground": "^2.1",
"prettus/l5-repository": "^2.6",
"spatie/laravel-medialibrary": "^9.4.0",
"spatie/laravel-permission": "^3.11",
"php-http/guzzle7-adapter": "^0.1.1",
"bensampo/laravel-enum": "^3.1.0",
"league/flysystem-aws-s3-v3": "~1.0"

Installation

  • Make sure you have run xamp/mamp/wamp/lamp for mysql and php

    • Create a database in your mysql and put those info in next step

    • Rename .env.example file to .env and provide necessary credentials. Like database credentials stripe credentials, s3 credentials(only if you use s3 disk) admin email shop url etc. Specially check for this env variables

      DB_HOST=localhost
      DB_DATABASE=pickbazar_laravel
      DB_USERNAME=root
      DB_PASSWORD=
    • Run composer install

      composer install

      composer success

    • run php artisan key:generate

      app key

    • Run php artisan marvel:install and follow necessary steps.

      pickbazar install

    • For image upload to work properly you need to run php artisan storage:link.

    storage link

    • run php artisan serve

      server start

NB: You must need to run php artisan marvel:install to finish the installation. Otherwise your api will not work properly. Run the command and follow the necessary steps.

NB: your frontend NEXT_PUBLIC_GRAPHQL_API_ENDPOINT env value will be localhost:8000/graphql

NB: your frontend NEXT_PUBLIC_REST_API_ENDPOINT env value will be localhost:8000/

For MAC and Linux(with sail and docker)

There is an alternate installation procedure for linux and mac. You can follow below procedure to getting started with sail

Prerequisites

  • Docker

Installation Mac

Video

REST API

Follow this tutorial for install REST API

GraphQL API

Follow this tutorial for install GraphQL

  • Run Docker application first
  • Now go to your pickbazar-laravel root directory and run bash install.sh. It will guide you through some process. Follow those steps carefully and your app will be up and running
  • Navigate to api then sail down to stop the container. If you want to remove the volumes then sail down -v

NB: your frontend NEXT_PUBLIC_GRAPHQL_API_ENDPOINT env value will be localhost/graphql

NB: your frontend NEXT_PUBLIC_REST_API_ENDPOINT env value will be localhost/

Configuration

All the configurations files are in packages/marvel/config folder. You can change any necessary configuration from these files. You can also publishes the shop configuration using artisan vendor:publish --provider="Marvel\ShopServiceProvider" --tag="config" command in your root folder.

  • Create .env file from our example.env file and put necessary configuration
  • By default s3 is using for media storage but you can also use local folder. Change MEDIA_DISK IN .env file as your need. Supported options are public and 's3`
  • Set Payment related configuration to STRIPE_API_KEY .env variable
  • Set ADMIN_EMAIL, SHOP_URL and necessary Database credentials.

Console Commands

  • php artisan marvel:install complete installation with necessary steps
  • php artisan marvel:seed seeding demo data
  • php artisan marvel:copy-files copy necessary files
  • php artisan vendor:publish --provider="Marvel\ShopServiceProvider" --tag="config" published the configuration file

All of the above custom command you will find in packages/marvel/src/Console folder.

Development

We have provided below two api.

  • REST API
  • GraphQL API

REST API

All the rest routes is resides in packages/marvel/src/Rest/Routes.php file and you can easily navigate to corresponding controller and necessary files.

Endpoints

https://documenter.getpostman.com/view/11693148/UVC5Fo9R

Folder structure

config

The packages/marvel/config folder contains all the config for our app.

database

The packages/marvel/database folder contains all the factories and migrations.

Enums

All the enums that are used throughout the app is in packages/marvel/src/Enums folder.

Events

All the events are in packages/marvel/src/Events folder.

Listeners

All the listeners corresponding to the above events are in packages/marvel/src/Listeners folder

Mail

All the mailables are in packages/marvel/src/Mails folder.

Notifications

Notifications related to order placed is reside packages/marvel/src/Notifications. Currently we have provided mail notification but you can easily add others notification system using laravel conventions.

Providers

All the secondary service providers that we have used in our app resides in packages/marvel/src/Providers folder. The main ShopServiceProviders reside in packages/marvel/src/ folder.

stubs

The packages/marvel/stubs folder contains all the necessary email templates and demo data related resources for the app.

GraphQL API

Laravel GraphQL API Endpoint

your_domain/graphql

To access the graphql api you will need a graphql client. GraphiQL is one of them. You can install it from below link(https://www.electronjs.org/apps/graphiql)

Alternatives

Folder Structure

All the code specifically related to GraphQL reside in packages/marvel/src/GraphQL/ folder.

  • Mutations:

    Folder contain necessary mutations files which is connected to rest Controller file for code reusability.

  • Queries:

    Folder contain necessary queries files which is connected to rest Controller file for code reusability.

  • Schema

    This is the most important part of the graphql api. Check the lighthouse-php(https://lighthouse-php.com/4.18/getting-started/installation.html) doc for understanding how schema works. We have provided schema for all the models in our app. If you check the above lighthouse-php doc you will understand how schema works and how you can modify it to your need.

Before Finishing up

Before you finishes the installation process make sure you have completed the below steps.

  • Copied necessary files and content to your existing laravel projects(if using existing projects)
  • Installed all the necessary dependencies.
  • Ran marvel:install commands and followed the necessary steps.
  • Created a .env file with all the necessary env variables in the provided projects.
  • Put DISK_NAME configuration for public or 's3`
  • Set Payment related configuration to STRIPE_API_KEY

Payment Gateway

We have used omnipay for payment and given stripe and cash_on_delivery default. We have used ignited/laravel-omnipay by forking it in our packages due to some compatibility issue with Laravel 8.

Extending The Functionality

If you want to extend the functionality of the app you can easily do it on your app. You would not need to modify code from our packages folder. Like you can add any routes and corresponding controller in your laravel app as your need. We highly suggest you to do all the modification in your app so you can update the package easily.

Deployment

Its a basic laravel application so you can deploy it as any other laravel application. Make sure you have installed all the php required plugins we mentioned above.