All Projects → Beachcasts → doctrine-expressive-example

Beachcasts / doctrine-expressive-example

Licence: MIT License
Example PHP REST API application built with Expressive using Doctrine ORM, complete with associations, pagination, and DB connectivity inside Docker containers. Used in #Beachcasts videos on YouTube.

Programming Languages

PHP
23972 projects - #3 most used programming language
TSQL
950 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to doctrine-expressive-example

doctrine-extensions
Doctrine2 behavioral extension Transformable
Stars: ✭ 14 (-61.11%)
Mutual labels:  doctrine-orm, doctrine2
orm
🔥 Well-integrated Doctrine ORM for Nette Framework
Stars: ✭ 51 (+41.67%)
Mutual labels:  doctrine-orm, doctrine2
docker-phpmyadmin
phpMyAdmin as Docker container, based on official image, always latest version
Stars: ✭ 40 (+11.11%)
Mutual labels:  docker-container
mindwendel
Create a challenge. Ready? Brainstorm. mindwendel helps you to easily brainstorm and upvote ideas and thoughts within your team.
Stars: ✭ 22 (-38.89%)
Mutual labels:  docker-container
fixtures
🔧 Doctrine Fixtures for Nette Framework
Stars: ✭ 15 (-58.33%)
Mutual labels:  doctrine2
docker-cheat-sheet
All about docker commands
Stars: ✭ 50 (+38.89%)
Mutual labels:  docker-container
factorio
Factorio headless server Docker container
Stars: ✭ 25 (-30.56%)
Mutual labels:  docker-container
docker
🐳 Official Docker image of the SinusBot for TeamSpeak 3 and Discord.
Stars: ✭ 50 (+38.89%)
Mutual labels:  docker-container
xiaomi-r3g-openwrt-builder
OpenWrt builder for any supported routers using Docker. Scheduled to run weekly
Stars: ✭ 25 (-30.56%)
Mutual labels:  docker-container
docker-qbittorrentvpn
Docker container which runs a qBittorent-nox client with an optional WireGuard or OpenVPN connection
Stars: ✭ 76 (+111.11%)
Mutual labels:  docker-container
docker-atlassian
A docker-compose orchestration for JIRA Software and Confluence based on docker containers.
Stars: ✭ 13 (-63.89%)
Mutual labels:  docker-container
vrnetlab
Run virtual routers with docker
Stars: ✭ 879 (+2341.67%)
Mutual labels:  docker-container
cart
Simple Symfony 4 shopping cart application. App boilerplate
Stars: ✭ 18 (-50%)
Mutual labels:  doctrine-orm
docker-cakephp
Example Dockerfile for deploying a CakePHP application in a Docker container, able to connect to a remote database with database-based sessions.
Stars: ✭ 31 (-13.89%)
Mutual labels:  docker-container
docker-aws-s3-sync
Docker container to sync a folder to Amazon S3
Stars: ✭ 21 (-41.67%)
Mutual labels:  docker-container
github-status-updater
Command line utility for updating GitHub commit statuses and enabling required status checks for pull requests
Stars: ✭ 83 (+130.56%)
Mutual labels:  docker-container
graph-vl
Self hosted identity verification layer with GraphQL.
Stars: ✭ 25 (-30.56%)
Mutual labels:  docker-container
docker-observium
Docker container for Observium Community Edition
Stars: ✭ 37 (+2.78%)
Mutual labels:  docker-container
bluechatter
Deploy & Scale a chat app using Cloud Foundry, Docker Container and Kubernetes
Stars: ✭ 64 (+77.78%)
Mutual labels:  docker-container
box-exec
Box execute is a npm package to compile/run codes (c,cpp,python) in a virtualized environment, Here virtualized environment used is a docker container. This packages is built to ease the task of running a code against test cases as done by websites used to practice algorithmic coding.
Stars: ✭ 17 (-52.78%)
Mutual labels:  docker-container

CircleCI

doctrine-expressive-example

Example PHP REST API application spread across 2 Docker containers. (1=Apache, 2=MySQL) I used Zend Expressive with Doctrine ORM in an effort to help document usage of both in a typical scenario. The application leveraged the zend-expressive-skeleton as a starting point, and was installed set up for Modules using FastRoute, zend-servicemanager, and no template engine (since it is a REST API responding with Json).

The Doctrine Entities also include example usage of Associations between Entities (see the OneToMany association in Bank using ArrayCollection to ManyToOne association in Branch) as well as parent-child relationships within the same Entity (See the Bank associations - ManyToOne $parent and OneToMany $children using ArrayCollection).

Knowledge shared through example

  • Zend Expressive usage
    • JsonResponse usage
    • Middleware usage
    • FastRoute usage
    • UrlHelper usage for hypermedia link creation
  • container-interop-doctrine usage
  • ramsey/uuid and ramsey/uuid-doctrine usages for primary keys in Announcements module, where routes also had to accommodate the UUID pattern of URLs - see the RoutesDelegator.php.
  • Doctrine ORM usage
    • OneToMany Bidirectional and self-referencing association example (See Bank and Branch Entities)
    • ManyToOne unidirectional association example (See Bank and Branch Entities)
    • ArrayCollection example (See Bank and Branch Entities)
    • EntityManager examples
    • RepositoryManager examples
    • Pagination usage (see Read Handlers)
    • Associations represented in data output (see View Handlers)
    • CLI config
  • PHP v7.2 feature usage

Installation

  • Step 1 - Clone this repo to desired location
  • Step 2 - Change directory to newly cloned repo via CLI cd /new/cloned/location
  • Step 3 - Run docker-compose docker-compose up -d
  • Step 4 - copy/rename the following config files
    • /config/autoload/development.local.php.dist >>> development.local.php
    • /config/autoload/doctrine.local.php.dist >>> doctrine.local.php
    • /config/autoload/local.php.dist >>> local.php
    • /config/development.config.php.dist >>> development.config.php
  • Step 5 (optional) - Use docker-compose to clean up the example application docker-compose down

Usage

At this point the REST API should work. (The following REST endpoints return a listing from the DB.)

Each of these can be called as an HTTP GET, or an HTTP POST with Json fields payload. (See example body content in docblocks of Create and Update Handlers. Sample Json data for requests can be found in /data.)

In addition to these endpoints the hypermedia in each response provides information to additional endpoints.

CLI Tools

Also, the Zend Expressive, Doctrine DBAL, and Doctrine CLI commands are available by gaining the terminal from Docker.

  • docker ps will provide the container ids to use in the following command.
  • docker exec -i -t {container-id} bash

Replace {container-id} with the Docker container ID from the docker ps for the web container.

Then from the root prompt the CLI tools are available. Example commands are:

  • php vendor/bin/doctrine list
  • php vendor/bin/doctrine-dbal list
  • php vendor/bin/expressive
  • or php vendor/doctrine/bin/doctrine list

Constructive advice welcome

This code is an example, but any advice to help make this a more awesome teaching tool is welcome. Please submit a ticket with details, or better yet, submit a pull request. Thank you.

Behavioral API testing

coming soon

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].