Giter Club home page Giter Club logo

symfony-api's Introduction

Symfony RESTful API

Setup Instructions

  1. Clone the repository:
    git clone https://github.com/eduduru/symfony-api.git
    cd symfony-api
    
  2. Install Dependencies->

composer install

  1. Set Up Environment Variables->

    Copy the .env.example file to .env

cp .env.example .env

  1. Generate JWT Keys to config/jwt directory->

    mkdir -p config/jwt openssl genrsa -out config/jwt/private.pem -aes256 4096 openssl rsa -pubout -in config/jwt/private.pem -out config/jwt/public.pem

  2. Set the passphrase in the .env file: JWT_PASSPHRASE=your_passphrase

  3. Set Up the Database->

    Create the database name is app:

    Run: php bin/console doctrine:database:create Run migrations to set up the database schema: php bin/console doctrine:migrations:migrate

    Load Fixtures: php bin/console doctrine:fixtures:load

  4. Run the Symfony Server-> symfony server:start

    If the symfony command is not available, use-> php -S localhost:8000 -t public

Docker Setup


Start Docker Containers:

Build Docker containers

docker-compose build

Build and run Docker containers:

docker-compose up -d

Start Docker containers

docker-compose up -d

Install Symfony dependencies

docker-compose exec app composer install

Create database schema

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

Run Database Migrations

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

Load Fixtures

docker-compose exec app php bin/console doctrine:fixtures:load

#Access the Application:

Open your web browser or postman and go to http://localhost:8000 (or the port specified in your Docker setup)

How it works

Here is the pipeline for getting an access to the api resources.

Register a new user account POST /api/register Smaple payload:

{
"username": "Chinedu",
"password": "password"

} Content-Type: application/json

HTTP1/1 200 OK Content-Type: application/json user: {} Login with the new account POST /login_check

Smaple payload: { "username": "Chinedu", "password": "password" }

Content-Type: application/json

HTTP1/1 200 OK Content-Type: application/json token: {} expiresIn: {} Use this generate token for accessing resources GET /user X-Auth-Token: {}

HTTP1/1 200 OK Content-Type: application/json user: {}

The API documentation link

https://documenter.getpostman.com/view/1838571/2sA3e5eojF

symfony-api's People

Watchers

Chinedu Duru 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.