GithubHelp home page GithubHelp logo

michaelharper / laravel-products-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 80 KB

A simple CRUD and RESTful API web service designed to manage product data.

Home Page: https://michaelharper.net

License: MIT License

PHP 61.64% JavaScript 0.30% Blade 38.06%
crud-application laravel laravel11x php php8 restful-api

laravel-products-api's Introduction

Laravel Logo

Laravel Products API

Description

The Laravel Products API is a RESTful web service designed to manage product data. It allows for the creation, retrieval, updating, and deletion of product information in a database, making it an ideal backend for e-commerce applications.

Built With

Laravel v11.16.0 and PHP v8.3.9

Installation

Clone the repository to your local machine:

git clone https://github.com/yourusername/laravel-products-api.git
cd laravel-products-api

Install the dependencies:

composer install

Set up your environment variables:

cp .env.example .env

Open the .env file and configure your database connection. You can specify either MySQL or SQLite. For MySQL, set the following:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_username
DB_PASSWORD=your_database_password

For SQLite, set the following:

DB_CONNECTION=sqlite
DB_DATABASE=/path_to_your_database/database.sqlite

After configuring the database, generate an application key:

php artisan key:generate

Run the migrations:

php artisan migrate

Start the server:

php artisan serve

Usage

To retrieve a list of products, send a GET request to /api/products.

Example request:

curl http://localhost:8000/api/products

Example response:

[
  {
    "id": 1,
    "name": "Product 1",
    "description": "This is a product",
    "price": 99.99
  },
  {
    "id": 2,
    "name": "Product 2",
    "description": "This is another product",
    "price": 89.99
  }
]

API Endpoints

Below are the available API endpoints for managing products:

  • GET /api/products - List all products.
  • POST /api/products - Create a new product.
  • GET /api/products/{id} - Get a specific product by its ID.
  • PUT /api/products/{id} - Update a product by its ID.
  • DELETE /api/products/{id} - Delete a product by its ID.

Sample Data

For testing and development purposes, you can find a sample data CSV with 300 test products in the repository. Access the sample data here: Sample Product Data.

Postman Collection

I've included the Postman Collection for testing the Laravel Products API. You can download it here: Laravel Products API Postman Collection.

Support

If you find Laravel Products API useful and would like to support its development, consider making a donation:

Buy Me A Coffee

Your contributions help ensure continued development and improvements to the extension.

License

This project is open-sourced software licensed under the MIT license.

laravel-products-api's People

Contributors

michaelharper avatar

Watchers

Lucian avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.