/realworld-backend-phel

WIP

Primary LanguagePHPOtherNOASSERTION

RealWorld Example App

Phel codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

This codebase was created to demonstrate a fully fledged backend application built with Phel including CRUD operations, authentication, routing, pagination, and more.

We've gone to great lengths to adhere to the Phel community styleguides & best practices.

For more information on how to this works with other frontends/backends, head over to the RealWorld repo.

  • Authentication Header
  • Authentication
  • Registration
  • Get Current User
  • Update User
  • Get Profile
  • Follow user
  • Unfollow user
  • List Articles
  • Feed Articles
  • Get Article
  • Create Article
  • Update Article
  • Delete Article
  • Add Comments to an Article
  • Get Comments from an Article
  • Delete Comment
  • Favorite Article
  • Unfavorite Article
  • Get Tags

How it works

Find more information about how to start with phel in getting started.

Getting started

Requirements

Phel requires at least PHP 8.0 and Composer.

Locally

  1. Ensure you have PHP >=8.0 (Some help about how to install multiple PHP versions locally on linux and Mac)
  2. Ensure you have composer
  3. Clone this repo
  4. Install the dependencies | composer install

Phel code

  1. Write your phel code in src/
  2. Execute your web server with
    • composer run:dev: it will recompile the code on every request
    • composer run:prod: it will run the same compiled code on every request

Database schema with Prisma Migrate

Install prisma as a dev dependency with npm

npm install

Use prisma db push or migrate dev commands

# schema prototyping
npx prisma db push

# schema migrations
npx prisma migrate dev

Tests

  1. Write your phel tests in tests/
  2. Execute your tests with composer test