Website π contributte.org | Contact π¨π»βπ» f3l1x.io | Twitter π¦ @contributte
Main goal is to provide best prepared API starter-kit project for Nette-Apitte developers.
Focused on:
- latest PHP 7.4 & 8.0
nette/*
packages- build PSR-7 API via
apitte/*
- 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/*
You can try it out yourself either by running it with docker, or more easily with docker-compose.
https://examples.contributte.org/apitte-skeleton/
Install with docker
-
At first, use composer to install this project.
composer create-project -s dev contributte/apitte-skeleton
-
After that, you have to setup Postgres >= 10 database. You can start it manually or use docker image
postgres:10
.docker run -it -p 5432:5432 -e POSTGRES_PASSWORD=apitte -e POSTGRES_USER=apitte postgres:10
Or use make task,
make loc-postgres
. -
Custom configuration file is located at
app/config/config.local.neon
. Edit it if you want.Default configuration should look like:
# Host Config parameters: # Database database: host: localhost dbname: apitte user: apitte password: apitte
-
Ok database is now running and application is configured to connect to it. Let's create initial data.
Run
NETTE_DEBUG=1 bin/console migrations:migrate
to create tables. RunNETTE_DEBUG=1 bin/console doctrine:fixtures:load --append
to create first user(s).Or via task
make build
. -
Start your devstack or use PHP local development server.
You can start PHP server by running
php -S localhost:8000 -t www
or use prepared make taskmake loc-api
. -
Open http://localhost and enjoy!
Take a look at:
- [GET] http://localhost:8000/api/public/v1/openapi/meta (Swagger format)
- [GET] http://localhost:8000/api/v1/users
- [GET] http://localhost:8000/api/v1/users?_access_token=admin
- [GET] http://localhost:8000/api/v1/users/1?_access_token=admin
- [GET] http://localhost:8000/api/v1/users/999?_access_token=admin
- [GET] http://localhost:8000/api/v1/users/email?email=admin@admin.cz&_access_token=admin
- [POST] http://localhost:8000/api/v1/users/create
Install with docker compose
-
At first, use composer to install this project.
composer create-project -s dev contributte/apitte-skeleton
-
Modify
app/config/config.local.neon
and set host todatabase
Default configuration should look like this:
# Host Config parameters: # Database database: host: database dbname: apitte user: apitte password: apitte
-
Run
docker-compose up
-
Open http://localhost and enjoy!
Take a look at:
- [GET] http://localhost/api/public/v1/openapi/meta (Swagger format)
- [GET] http://localhost/api/v1/users
- [GET] http://localhost/api/v1/users?_access_token=admin
- [GET] http://localhost/api/v1/users/1?_access_token=admin
- [GET] http://localhost/api/v1/users/999?_access_token=admin
- [GET] http://localhost/api/v1/users/email?email=admin@admin.cz&_access_token=admin
- [POST] http://localhost/api/v1/users/create
Since we have OpenAPI specification available at /api/public/v1/openapi/meta
you just need to add UI for it (e.g. to www/doc
directory or as a standalone application).
Available options are:
- Swagger UI + themes
- ReDoc
- other
Here is a list of all features you can find in this project.
- PHP 7.4+
- π¦ Packages
- Nette 3.0
- Apitte
- Contributte
- Nettrine
- π³ Structure
app
config
- configuration filesenv
- prod/dev/test environmentsapp
- application configsext
- extensions configsconfig.local.neon
- local runtime configconfig.local.neon.dist
- template for local config
domain
- business logic and domain specific classesmodel
- application backbonemodule
- API moduleresources
- static content for mails and othersbootstrap.php
- Nette entrypoint
bin
- console entrypoint (bin/console
)db
- database filesfixtures
- PHP fixturesmigrations
- migrations files
docs
- documentationlog
- runtime and error logstemp
- temp files and cachetests
- test engine and many casestests/cases/E2E
- PhpStorm's requests files (api.http
)tests/cases/Integration
tests/cases/Unit
vendor
- composer's folderwww
- public content
- β Tracy
- Cool error 500 page
Take a detailed look π at each single package.
- contributte/bootstrap
- contributte/di
- contributte/http
- contributte/security
- contributte/utils
- contributte/tracy
- contributte/console
- contributte/neonizer
- contributte/monolog
Apitte
Nettrine
Nette
Symfony
See how to contribute to this package.
This package is currently maintaining by these authors.
Consider to support contributte development team. Also thank you for using this project.