Skip to content

Lavendar77/simple-crud

Repository files navigation

Thought For The Developer

The purpose of this project is to allow users to create an account, then, drop a comment or more for the developer. I like to call them thoughts.

Table of Content

  1. Development
  2. API Documentation
  3. How It Works

Development

This project is developed using Symfony (4).

Setup

  1. Install dependencies
composer install
  1. Database configuration

    • Configure your .env: DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name
    • Create the database: php bin/console doctrine:database:create
    • Create the database schema: php bin/console doctrine:schema:create
  2. Generate the SSH keys (for JWT Token Configuration):

$ mkdir -p config/jwt
$ openssl genpkey -out config/jwt/private.pem -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096
$ openssl pkey -in config/jwt/private.pem -out config/jwt/public.pem -pubout

In my case, I used PuttyGen to generate a key and saved the private key as private.pem. Then, ran the second command: openssl pkey -in config/jwt/private.pem -out config/jwt/public.pem -pubout.

  1. Start your server
symfony serve:start --no-tls`

API Documentation

Run in Postman

How It Works

Authentication

  • Create an account (first_name, last_name, email, password, created_at, updated_at)
  • Login (email, password)

Main Operation

Thought::entity - id, user_id, comment, created_at, updated_at

  • List all your thoughts (GET /thoughts)
  • Store a thought (POST /thoughts)
  • Show a thought (GET /thoughts/{thought})
  • Edit a thought (PUT /thoughts/{thought})
  • Delete a thought (DELETE /thoughts/{thought})

Testing

Okay, so testing has been stressful and quite annoying to be frank 🙄
But we'll pull through 🚀

Steps to take

  1. Edit your .env.local file (duplicate .env into .env.local if you haven't done so already)
    APP_ENV=test
  2. Duplicate .env.test into .env.test.local
  3. Set up your test database
    php bin/console doctrine:database:create
  4. Load up the fixtures
    php bin/console doctrine:fixtures:load
  5. Run the tests
    php bin/phpunit

Functional Tests

For now, only functional tests are available. Codebase is still a bit buggy, but one step at a time.
Please set up your TEST_USER_EMAIL and TEST_USER_PASSWORD in your .env.test.local.

  1. Registration
    Testing for both successful and failed requests.
  2. Login
    Testing for both successful and failed requests.
  3. Profile Access
  4. Main CRUD [Thoughts]

About

Quick Task in Symfony

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published