/api_demo

Small Product/Bundle management API based on Symfony 4

Primary LanguagePHP

How to start

git clone git@github.com:leobeal/api_demo.git
cd api_demo

cp env.dist .env

composer install
  • Adjust DB settings in .env
#Creates the db
php bin/console doctrine:database:create
#Creates tables
php bin/console doctrine:schema:update --force
#Creates dummy products
php bin/console doctrine:fixtures:load --append

Routes available

routes

Online example

The docs for a working version of this demo can be found here. Products can be seen here

Using Postman

A Json postman colletion is available for convinient testing of the application. It can be found here or here

Docs

Api docs are available under /docs. Calls made to the api from docs might not work, as authentication is required. Use postman instead.

Permissions

  • Admins can create products and bundles.
  • Normal users can see products, add a product to a cart, and create an order.

Before you are able to run the application, the user table need to be populated, as requests to

insert into category (name, created_at, updated_at) values ("Category name", NOW(), NOW());

INSERT INTO `user` (`id`, `username`, `api_key`, `created_at`, `updated_at`)
VALUES
	(1, 'normal user', 'api_key_user',  NOW(),  NOW()),
	(2, 'admin user', 'api_key_admin',  NOW(),  NOW());

Running tests

./vendor/bin/simple-phpunit

Database model

routes