majksa / api-template
GraphQL API template in Nette
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Forks: 1
Type:project
pkg:composer/majksa/api-template
Requires
- php: 8.0.*
- ext-openssl: *
- beberlei/porpaginas: ^1.2
- code-lts/u2f-php-server: ^1.2
- contributte/bootstrap: ^0.5.0
- contributte/console: ^0.9.0
- contributte/di: ^0.5.0
- contributte/http: ^0.4.0
- contributte/monolog: ^0.6.0
- contributte/tracy: ^0.5.0
- contributte/utils: ^0.5.0
- gmostafa/php-graphql-client: ^1.13
- maxa-ondrej/nette-di: 1.0.0
- maxa-ondrej/nette-graphql: ^1.1.0
- myclabs/php-enum: ^1.8
- nettrine/annotations: ^0.7.0
- nettrine/dbal: ^0.7.0
- nettrine/fixtures: ^0.6.0
- nettrine/migrations: ^0.7.0
- nettrine/orm: ^0.8.0
- thecodingmachine/graphqlite-symfony-validator-bridge: ^5.0
Requires (Dev)
- contributte/dev: ^0.3
- dg/bypass-finals: ^1.3
- jetbrains/phpstorm-attributes: ^1.0
- mockery/mockery: ^1.3.0
- nelmio/alice: ^3.5.8
- ninjify/nunjuck: ^0.4
- orisai/coding-standard: ^2.2
- phpstan/phpstan: ^1.0
- phpstan/phpstan-doctrine: ^1.0
- phpstan/phpstan-nette: ^1.0
- phpstan/phpstan-phpunit: ^1.0
This package is not auto-updated.
Last update: 2025-10-20 10:24:49 UTC
README

Goal
Main goal is to provide best prepared GraphQL API starter-kit project in Nette with user registration and login.
Focused on:
- latest PHP 8.0
- mariadb
- nette/*packages
- GraphQL via maxa-ondrej/nette-graphql(and graphqlite)
- Doctrine ORM
via nettrine/*
- Symfony components via contributte/*
- codestyle checking via CodeSniffer and ninjify/*
- static analysing via phpstan
- unit / integration tests via Nette Tester and ninjify/*
Summary
Initial Configuration
Since it is all running inside docker containers, no additional configuration is needed! Though you need to install some tools first:
- docker and docker compose (included in docker from version 3.4)
Optional:
- make - for easier scripts configuration
- php8.0 and composer - if you want to run tests without having to start docker containers
Installation
- Create a local copy of docker-compose.local.dist.yml- cp docker-compose.local.dist.yml docker-compose.local.yml
 
- Start the server and run database migrations:
- And the backend is up and running on url: http://localhost:8080/graphql
If you wish to change the port, you can do so in docker-compose.local.yml: services > server > ports
Using Makefile
If you have installed Make, you can follow the steps bellow for the easiest setup.
- make compose-dev- starts docker network
- make prepare-db- runs database migrations and generates testing fixtures
Using docker compose
- docker compose -f docker-compose.local.yml up -d --force-recreate --build --remove-orphans- starts docker network
- docker exec -e NETTE_DEBUG=1 apitte-skeleton-app-1 bin/console orm:schema-tool:drop --force --full-database- drop the database schema
- docker exec -e NETTE_DEBUG=1 apitte-skeleton-app-1 bin/console migrations:migrate --no-interaction- runs database migrations
- docker exec -e NETTE_DEBUG=1 apitte-skeleton-app-1 bin/console doctrine:fixtures:load --no-interaction --append- generates testing fixtures
Quality Assurance
To make sure our code quality, we use 3 different tools:
- CodeSniffer: for formatting
- PHPStan: for static analysis
- Nette Tester: for running tests
You can simply run all of them using composer run-script qa.
To make sure these tools run before every commit, please run: git config core.hooksPath .hooks
Formatting
We follow some basic conventions, which are set up in phpcs.xml file.
- formatting and optimizing the code, run composer run-script cbf
- just analysis, run composer run-script cs
Static Analysis
To prevent common and easy to find mistakes, we run a very useful tool PHPStan.
- composer run-script phpstan
Running tests
Tests are a really important part of coding and exposes most errors before deployment.
To create a new TestCase, you can simply duplicate any existing Test inside /tests/Unit folder. \
If you wish to add a new integration test, create a new TestCase in /tests/Integration folder.
- running all tests: composer run-script tests
- running test coverage: composer run-script coverage
Running GraphQL request
Easiest way to run request to the api is using Altair.
Tracy bar
If you want to display the Tracy bar, that's definitely possible!
Just copy the query - and variables if there are any- and add them inside the [GET] request as query
and variables: