Skip to content
/ php-api Public template

PHP RESTful API with Doctrine, Entities, JWT and Pre-done Auth!

License

Notifications You must be signed in to change notification settings

germondai/php-api

Repository files navigation

PHP RESTful API with Doctrine integration. Own Api & Entity Controller that handles routing of Model/Action and Entity with CRUD options based on Request Method. Doctrine Console, Entities and Migrations to create flawless ORM Schemas. Custom useful Utils like Token that manages JSON Web Tokens (JWT). Pre-done Auth Model, User Entity connected with Media Entity by OneToMany Relation to keep track of Author of uploaded media files (optimize, resize and image format/type change included). Easy configuration and safe .env variables.

⚡️ Features

Overview

  • Own REST API System
    • Routing
    • Auth
    • CRUD
    • Media
      • Upload
      • Optimize
      • Resize
      • Quality
      • Format
  • Doctrine
    • ORM
    • DBAL
    • Entities
    • Migrations
    • Annotations
  • Custom Utils
    • Helper
    • Database
    • Doctrine
    • JSON Web Tokens (JWT)
  • Nette
    • Database Explorer
    • Tracy
  • Environment (.env)

🧬 Structure

app/ - App's Main Code (Controller, Entity, Model)
bin/ - Console for Doctrine
migrations/ - Doctrine DB Migrations
public/ - Accessible from Outside (Routing, Media)
src/ - Developer Source Files (Assets, Includes, Utils)
temp/ - Storage for Temporary Files and Logs

🧠 Technologies

🛠️ Installation Instructions

Requirements

Install dependencies

composer install

Setup .env

  • Database Credentials
  • JWT Secret and Algorithm
# to dupe example.env as .env
cp example.env .env

📝 Entity Guide

Entity CRUD operations depends on Request Methods
Entity Schema returns tables / table with columns

Routes

Operations: /[entity]/[id]

  • GET - Read
  • POST - Create
  • PUT - Replace
  • PATCH - Update
  • DELETE - Delete
  • OPTIONS - Preflight (always return 200)

Schema: /schema/[entity]

📚 Doctrine Guide

The Doctrine console is in "bin/console"
EntityManager config location "src/Utils/Doctrine.php"
Base migrations config, which is in root "migrations.php"
And migration files are stored in "migrations/"

Console

# To run doctrine console
php bin/console ...

# if you need commands list
php bin/console list

Made with ❤️ by @germondai