Skip to content

eduardoguerrero/phone-book-api

Repository files navigation

1. Start the container

Change to docker directory

cd /path/your/project/phone-book-api/docker 
❯ docker-compose up -d

Run docker ps to find out the name of your php container. It should look like this lillydoo_php.

❯ docker ps
CONTAINER ID   IMAGE                   COMMAND                  CREATED        STATUS         PORTS                                                      NAMES
f034770755b0   docker_apache           "/bin/sh -c 'apachec…"   30 hours ago   Up 2 minutes   443/tcp, 9000/tcp, 0.0.0.0:8002->80/tcp, :::8002->80/tcp   lillydoo_apache
8452cd2aa618   phpmyadmin/phpmyadmin   "/docker-entrypoint.…"   30 hours ago   Up 2 minutes   0.0.0.0:8080->80/tcp, :::8080->80/tcp                      lillydoo_phpmyadmin
b5bbb40c2744   docker_php              "docker-php-entrypoi…"   30 hours ago   Up 2 minutes   9000/tcp                                                   lillydoo_php
c49b36812f21   mariadb:10.2            "docker-entrypoint.s…"   30 hours ago   Up 2 minutes   3306/tcp, 0.0.0.0:3307->3307/tcp, :::3307->3307/tcp        lillydoo_mariadb

Then you can enter the php container

❯ docker exec -it -u dev lillydoo_php bash

In the container: Initialization

❯ composer install
❯ php bin/console doctrine:database:create
❯ php bin/console doctrine:migrations:migrate
❯ php bin/console doctrine:fixtures:load -n
❯ php bin/console cache:clear 

Start symfony server

  • You can start the symfony web server typing following into your local shell
cd /path/your/project/phone-book-api 
❯ symfony server:start

If you need it, change web server listening in line 4 and line 6 in fileconfig/packages/nelmio_api_doc.yaml

You have successfully set up your coding dev environment. You can now access the api documentation in your browser.

http://127.0.0.1:8000/api/doc

Alt text

  • You can access the database by typing following into your local shell or using phpmyadmin
❯ docker exec -it lillydoo_mariadb bash -l
❯ mysql -uroot -proot

To browse your documentation with Swagger UI

http://127.0.0.1:8000/api/doc.json

Execute a request

Get all contacts with curl or Postman

❯ curl --location --request GET 'http://127.0.0.1:8000/api/contacts'

Alt text

Run tests

Then you can enter the php container and typing following into your local shell

./vendor/phpunit/phpunit/phpunit

Alt text

@TODO

Add JWT authentication

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published