PHP Classes

How to Implement a PHP E-commerce Website Using Laravel with the Package Laravel Simple E-commerce: Show and sell products on a Web site

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-12-15 (Yesterday) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
laravel-simple-ecomm 1.0.0The PHP License7E-Commerce, Libraries, Web services, P...
Description 

Author

This package can show and sell products on a Web site.

It provides a Web application and an API to retrieve products for sale and process sales of those products.

Currently, it can:

- Process user registration and login

- Retrieve lists of products or individual products available for sale.

- Add, update, list, and remove products to a shopping cart

- List, view, and update product orders

Picture of Hicri
  Performance   Level  
Innovation award
Innovation award
Nominee: 4x

Winner: 1x

 

Example

<?php

use Illuminate\Http\Request;
use
Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/

//Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
// return $request->user();
//});
Route::post('/auth/login',[\App\Http\Controllers\Auth\LoginController::class, 'login'])->name('login');
Route::post('/auth/register',[\App\Http\Controllers\Auth\RegisterController::class, 'store']);

Route::group(['middleware' => 'auth:api'], function ($router) {

   
Route::post('/auth/logout',[\App\Http\Controllers\Auth\LogoutController::class, 'logout'])->middleware('throttle:30,1');
   
Route::post('/auth/refresh',[\App\Http\Controllers\Auth\LoginController::class, 'refresh'])->middleware('throttle:30,1');

   
Route::get('/products', [\App\Http\Controllers\ProductController::class, 'index'])->middleware('throttle:30,1');
   
Route::get('/products/{id}', [\App\Http\Controllers\ProductController::class, 'show'])->where('id', '[0-9]+')->middleware('throttle:30,1');
   
Route::post('/products', [\App\Http\Controllers\ProductController::class, 'store'])->middleware('is_admin','throttle:30,1');
   
Route::put('/products/{id}', [\App\Http\Controllers\ProductController::class, 'update'])->where('id', '[0-9]+')->middleware('is_admin','throttle:30,1');
   
Route::delete('/products/{id}', [\App\Http\Controllers\ProductController::class, 'delete'])->where('id', '[0-9]+')->middleware('is_admin','throttle:30,1');

   
Route::get('/cart', [\App\Http\Controllers\CartController::class, 'index'])->middleware('throttle:30,1');
   
Route::post('/cart/items', [\App\Http\Controllers\CartController::class, 'store'])->middleware('throttle:30,1');
   
Route::put('/cart/items/{id}', [\App\Http\Controllers\CartItemController::class, 'update'])->where('id', '[0-9]+')->middleware('throttle:30,1');
   
Route::delete('/cart/items/{id}', [\App\Http\Controllers\CartItemController::class, 'delete'])->where('id', '[0-9]+')->middleware('throttle:30,1');

   
Route::get('/orders', [\App\Http\Controllers\OrderController::class, 'index'])->middleware('throttle:30,1');
   
Route::post('/orders', [\App\Http\Controllers\OrderController::class, 'store'])->middleware('throttle:30,1');
   
Route::get('/orders/{id}', [\App\Http\Controllers\OrderController::class, 'show'])->where('id', '[0-9]+')->middleware('throttle:30,1');

});



Details

Contents

PHP
Composer
Docker
MySQl
Redis
Jwt
Nginx
Testing
Rate limiting

Installation

docker compose up -d --build 
docker compose exec app bash
chmod -R 777 /var/www/html/storage/ /var/www/html/bootstrap/
cp .env.example .env
composer install
docker compose exec app php artisan jwt:secret
docker compose exec app php artisan migrate:fresh --seed

env config

  • mysql
    DB_CONNECTION=mysql
    DB_HOST=db
    DB_PORT=3306
    DB_DATABASE=laravel
    DB_USERNAME=laravel
    DB_PASSWORD=laravel
    
  • redis
    CACHE_DRIVER=redis
    REDIS_CLIENT=predis
    REDIS_HOST=redis
    REDIS_PASSWORD=null
    REDIS_PORT=6379
    
    ### Usage
    
    Insomnia_2024-12-13.json

Testing

cp .env .env.testing
docker-compose exec app php artisan config:clear
docker-compose exec app php artisan cache:clear
docker-compose exec app php artisan config:cache
docker-compose exec app php artisan migrate:fresh --seed --env=testing
docker-compose exec app php artisan test
  • env.testing
    APP_ENV=testing
    DB_CONNECTION=mysql
    DB_HOST=db
    DB_PORT=3306
    DB_DATABASE=laravel
    DB_USERNAME=laravel
    DB_PASSWORD=laravel
    

  Files folder image Files (133)  
File Role Description
Files folder imageapp (8 directories)
Files folder imagebootstrap (1 file)
Files folder imageconfig (16 files)
Files folder imagedatabase (3 directories)
Files folder imagedocker (2 directories)
Files folder imagepublic (3 files)
Files folder imageresources (2 directories)
Files folder imageroutes (4 files)
Files folder imagetests (2 files, 2 directories)
Accessible without login Plain text file .env.example Data Auxiliary data
Accessible without login Plain text file .env.testing Data Auxiliary data
Plain text file artisan Class Class source
Accessible without login Plain text file build.sh Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file docker-compose.yml Data Auxiliary data
Accessible without login Plain text file entrypoint.sh Data Auxiliary data
Accessible without login Plain text file Insomnia_2024-12-13.json Data Auxiliary data
Accessible without login Plain text file package.json Data Auxiliary data
Accessible without login Plain text file php.root.Dockerfile Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file vite.config.js Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads  
 100%
Total:0
This week:0