Code Monkey home page Code Monkey logo

demo-api's Introduction

Install

Setup Domain name

cp .env.example .env

edit .env file and set SERVER_NAME

SERVER_NAME=consent.local

Also, you can config your db name and credentials.

Build and Start containers

docker-compose build --pull --no-cache
docker-compose up -d

Getting OS X to trust self-signed SSL certificates

Set your os always trust to below certificate

docker compose cp caddy:/data/caddy/certificates/local/consent.local/consent.local.crt /any/location/in/your/machine

See https://tosbourn.com/getting-os-x-to-trust-self-signed-ssl-certificates/

Set local host for dev

sudo echo '127.0.0.1 example.local' >> /etc/hosts

Auth with JWT

Generate key pair for your local We can automate this step only for dev envs because in live env we should never update our keypair

# Composer require is already done, composer.json updated
# docker-compose exec php composer require jwt-auth

# This step needs to be done for your local setup
docker-compose exec php sh -c '
    set -e
    apk add openssl
    php bin/console lexik:jwt:generate-keypair
    setfacl -R -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt
    setfacl -dR -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt
'

Testing and Fixtures

cp phpunit.xml.dist .phpunit.xml
# These steps are already done, Just documented for the next services
docker-compose exec php composer require --dev alice
docker-compose exec php composer require --dev symfony/test-pack symfony/http-client justinrainbow/json-schema

DB and Migrations

Create db for first time

docker-compose exec php bin/console doctrine:database:create

Make and run Migrations

After changing the mappings of your entities you can generate migrations and run them against your db

docker-compose exec php bin/console make:migration
docker-compose exec php bin/console doctrine:migrations:migrate

Also you can update db schema without generating migrations

docker-compose exec php bin/console doctrine:schema:update

Seeding Database

Seed your local db to have some data, Write your fixtures in api/fixtures directory

docker-compose exec php bin/console hautelook:fixtures:load

Running Tests

docker-compose exec php bin/console doctrine:database:create --env=test
docker-compose exec php bin/console doctrine:migration:migrate --env=test
docker-compose exec php bin/phpunit

Doctrine Annotations for PHP 8.0 Read the official "Getting Started" guide.

Credits

Created by Kévin Dunglas. Commercial support available at Les-Tilleuls.coop.

demo-api's People

Contributors

sr13hosseini avatar sr-hosseyni avatar rasskec avatar

Watchers

James Cloos 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.