Skip to content

Latest commit

History

History
52 lines (36 loc) 路 1.57 KB

File metadata and controls

52 lines (36 loc) 路 1.57 KB

API Skeleton

Example native Nette API project using contributte/api.

Requirements

Create the native Nette API

Create the distributed project, copy its local configuration, and prepare writable runtime directories:

composer create-project contributte/api-skeleton acme
cd acme
cp config/local.neon.example config/local.neon
mkdir -p var/tmp var/log
chmod 0777 var/tmp var/log

The package distribution excludes the repository Makefile, so setup uses the direct commands above. Composer already installs dependencies during project creation.

Run and verify the API

NETTE_DEBUG=1 NETTE_ENV=dev php -S 0.0.0.0:8000 -t www www/index.php

Passing www/index.php as the router lets the PHP development server handle API paths; the repository make dev target omits it. The server listens on http://localhost:8000. In another terminal, verify it:

curl http://localhost:8000/api/_/ping
# pong

Discover the API contract

Open http://localhost:8000/api/_/apidoc to discover the available API routes and their request and response schemas.

Develop the repository checkout

Repository contributors can use these Make targets; they are not included in projects installed from the package distribution:

make qa       # coding standard and static analysis
make tests    # Nette Tester suite
make cs       # coding standard check
make csf      # fix coding standard issues
make phpstan  # static analysis
make coverage # generate coverage output