liketomove / api-ddd-template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

api-ddd-template

  1. About project
  2. Installation
  3. Configure environment variables and create database
  4. Run project
  5. Run Tests
  6. Future improvements

About project

  • Symfony 4.4
  • Packages installed: Symfony Flex, Doctrine, Security, NelmioApiDocBundle, MakerBundle, DoctrineFixturesBundle and PHPUnit among others
  • DDD and Hexagonal architecture
  • Best practices: Clean code, PHP Standards Recommendations (PSR), SOLID principles and design patterns
  • Unit testing
  • Exceptions handler
  • Database full dump with test data included in migrations folder

Installation

Clone repository:

git clone https://github.com/burus86/api-ddd-template.git

Install dependencies:

cd api-ddd-template

composer install

Configure environmment variables and create database

Rename filename .env.dist as .env and edit DATABASE_URL value with database parameters

Execute the following commands to create an empty database with the name specified in .env filename:

php bin/console doctrine:database:create

php bin/console doctrine:schema:update --force

Execute the following command in order to dump fake data in database tables:

php bin/console doctrine:fixtures:load

Alternatively, you can either import the db-api-ddd-template-full.sql file, included in migrations folder, to create and populate the database schema, however this file might not be up to date.

Run project

Follow instructions to install a Symfony Local Web Server and then open a new tab with the following URL:

http://127.0.0.1:8000/api/doc

Alternatively, if you use XAMPP, open the URL:

http://localhost/api-ddd-template/public/api/doc

All API endpoints require a X-AUTH-TOKEN in header, with a value equal to field api_token in user table. Example: cU70Sbr0qKrUQHE0tw60XQVMwBP8hJrdRMY61xhX

Captura

Captura

Run Tests

vendor/bin/phpunit

Future improvements

About


Languages

Language:PHP 98.9%Language:Twig 1.1%