Giter Club home page Giter Club logo

bookshop-php-api's Introduction

bookshop-php-api

PHP API for my Bookshop Webstore

Table of Contents

About the Project

This is the API for my Bookshop Webstore. It is written in PHP and uses MySQL as the database. It is used to fetch data from the database and send it to the webstore. It also handles the payment process via Stripe.

Getting Started

Requirements

I recommend using XAMPP to setup the database and the API. It comes with Apache, MariaDB, PHP and phpMyAdmin. But you can also use any other server and database that supports PHP and MySQL.

Setup

Database

  1. Start XAMPP and start Apache and MariaDB.
  2. Open phpMyAdmin and create a new database called bookshop using the SQL command:
CREATE DATABASE bookshop;
  1. Import the bookshop.sql file from the db folder into the database.

In bookshop.sql are the necessary SQL statements to create the database and the tables so you don't have to do it manually. This step is necessary and the API won't work without it, because it needs to make queries to the database, in order for the webstore to work.

API

  1. Copy the api folder into the htdocs folder of XAMPP. This folder contains all the PHP files that make up the API.
  2. Copy the admin folder into the htdocs folder of XAMPP. This folder contains config.php which contains the database credentials and the stripe secret key. You need change the stripe secret key and database credentials to your own.
  3. Copy the conf folder into the htdocs folder of XAMPP. This folder .htpassword which contains the credentials for the admin page. You need to change the credentials to your own. I recommend saving only a hashed password in the file. You can use this tool to generate a hashed password.
  4. The API is set to allow CORS requests from http://localhost:3000 by default. If you want to change this, you can do so in admin/config.php by changing the Access-Control-Allow-Origin header. You can also search for all occurrences of http://localhost:3000 in the api folder and change them to your own domain. The URL is used in config.php, success.php and cancel.php and .htaccess in the api folder. Visual Studio Code has a handy feature to search for all occurrences of a string in the project.

TLDR:

  1. Copy everything to htdocs inside XAMPP folder.
  2. Change the stripe secret key, database credentials and admin credentials in config.php
  3. Change BASE_URL from http://localhost:3000 to your own domain.

Congrats! The API is now setup and ready to use.

WARNING Never expose your stripe secret key or sensitive credentials to the public. Use gitignore to hide them from git. If you are using a public repository, make sure to remove the credentials from the commit history.

Images

  • Check docs/imgs.md for instructions on how to upload and display images in the database.

bookshop-php-api's People

Contributors

jamal-alkharrat avatar

Watchers

 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.