Skip to content

tarlepp/symfony-flex-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7,602 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is this?

MIT licensed CI Coverage Status Psalm coverage Scrutinizer Code Quality Code Intelligence Status Maintainability Sonarcloud Quality Gate Sonarcloud Vulnerabilities Sonarcloud Vulnerabilities Sonarcloud Vulnerabilities OpenSSF Scorecard

JSON REST API which is built on top of Symfony framework.

This application is meant to be used as an API that frontend applications or different backend applications can use as needed. One example frontend is this Angular template, though you can use any frontend solution.

Quick Start

git clone https://github.com/tarlepp/symfony-flex-backend.git
cd symfony-flex-backend
make start

Then open https://localhost:8000 in your browser. For more details, see Installation.

Table of Contents

Requirements

If you are not using Docker Engine, follow this.

Recommendations

  • *nix platform - most likely you're going to host your application on *nix platform - so I would recommend to do development also on that platform.
  • WSL2 on Windows - if you develop on Windows, use WSL2 to get a Linux-like development environment for Docker and tooling.
  • Dev Container capable IDE - recommended for the quickest setup (e.g. VS Code or JetBrains IDEs with Dev Container support).
  • Makefile support - recommended if you run containers with Make commands; if you do not have make, check Makefile to see equivalent Docker commands.

Installation

This installation guide expects that you're using Docker Engine.

1. Clone repository

Use your favorite IDE and check out the repository from GitHub, or use the following command:

git clone https://github.com/tarlepp/symfony-flex-backend.git

2. Start containers

You can run this project either with Dev Containers (for example in VS Code or JetBrains IDEs) or with Make commands.

For Dev Containers, open this repository in your IDE and use its Dev Container workflow to reopen/start the project in a container (see Dev Containers section for details).

If you want to use Make commands instead, run the following command, which will start all the containers:

make start

If you want to start containers in the background, use the following command:

make daemon

These commands will create following containers to run this backend application:

  • php (this is for actual application)
  • nginx (this will serve application)
  • mariadb (MariaDB 10.7 which will store all the data of application)
  • dozzle (to see your docker container logs)
  • adminer (to manage your database via browser)

For next steps (application URLs, shell access, and rebuilding containers), see Running the application.

Running the application

These instructions are shared for both Make-based and Dev Container-based workflows.

Using application

When containers are running (either via Make commands or Dev Containers), following ports are exposed on localhost on your host machine:

And this application is usable in your browser at https://localhost:8000. When you open that site for the first time, you will see a "Your connection is not private" warning - see this to resolve that.

Another choice is to use http://localhost:8080, which does not use SSL.

MariaDB credentials:

user: root
password: password

Note: These credentials are for local development only and should never be used in production.

Getting shell to container

After you've started containers (make start / make daemon or via Dev Containers), you can list all running containers with docker ps.

To get shell (bash or fish) access inside one of those containers, run the following command:

make bash

or

make fish

If you are using Dev Containers, you can also use the IDE terminal that is already attached to the php container.

Building containers

From time to time you probably need to build containers again. This is something that you should do every time if you have some problems getting containers up and running.

If you use Make commands, rebuild/start containers with:

make daemon-build

If you want to see container logs directly, use the following command:

make start-build

If you use Dev Containers, use your IDE's Dev Container rebuild action (for example, "Rebuild Container" / "Rebuild and Reopen in Container").

If you prefer CLI, you can rebuild with:

docker compose -f compose.yaml -f .devcontainer/docker-compose.devcontainer.yml build
docker compose -f compose.yaml -f .devcontainer/docker-compose.devcontainer.yml up -d php mariadb nginx dozzle adminer

Health check

To verify your setup is working correctly, you can check:

# Check container status
docker compose ps

# Test HTTP endpoint
curl -I http://localhost:8080

# Test HTTPS endpoint (ignore SSL warning)
curl -k -I https://localhost:8000

Alternatively, you can use Dozzle (container log viewer) to monitor all services:

  • Open http://localhost:8100 in your browser
  • View real-time logs for all running containers
  • Check container status and resource usage

Dev Containers

This project also includes a Dev Container setup in .devcontainer/ that can be used from VS Code and JetBrains IDEs with Dev Container support.

When you reopen the repository in a container, it starts the full Docker Compose stack:

  • php
  • nginx
  • mariadb
  • dozzle
  • adminer

For application URLs, shell access, and rebuild commands, see Running the application.

For detailed usage, UID/GID notes, and port mappings, see .devcontainer/README.md.

Frontend?

This backend API can be consumed by any frontend technology or framework. You can use React, Vue, Angular, Svelte, or any other frontend solution that can make HTTP requests.

As a reference example, I've created an Angular NgRx powered frontend template project that works with this backend. It demonstrates how to integrate with this API, but you're free to use any technology stack that fits your project needs.

With this backend, it should be quite easy to start building your own application with the frontend technology of your choice.

Resources

External links / resources

Authors

License

The MIT License (MIT)

Copyright © 2024 Tarmo Leppänen

About

Symfony Flex REST API template project

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors