graviton/graviton

The base package for graviton

Installs: 9 865

Dependents: 1

Suggesters: 0

Security: 0

Stars: 13

Watchers: 18

Forks: 10

Open Issues: 2

Type:project

v7.5.5 2024-03-25 08:45 UTC

This package is auto-updated.

Last update: 2024-03-25 08:46:25 UTC


README

CI Coverage Status Packagist Version Packagist Downloads Packagist License

Graviton is a Symfony and Doctrine Mongo ODM based REST server generation toolkit. So it stores all data in MongoDB.

You can define your REST service in an simple JSON format, run the generator - and voilà - your REST API is ready to go.

Let's say you define this file:

{
  "id": "Example",
  "service": {
    "readOnly": false,
    "routerBase": "/example/endpoint/"
  },
  "target": {
    "fields": [
      {
        "name": "id",
        "type": "string"
      },
      {
        "name": "data",
        "type": "string"
      }
    ]
  }
}

Then you run the generator

php bin/console graviton:generate:dynamicbundles

And once running, you will have a full RESTful endpoint at /example/endpoint, supporting GET, POST, PUT, DELETE and PATCH as well as a valid generated JSON schema endpoint, pagination headers (Link as github does it) and much more.

The generated code are static PHP files and configuration for the Serializer and Symfony and is regarded as disposable. You can always regenerate it - don't touch the generated code.

The application is highly optimized for runtime performance, particurarly in the context of PHP-FPM with activated opcache.

It boasts many additional features (such as special validators and many flags and configurations) which are currently mostly undocumented as this project was not built for public usage in mind. But if there is interest and support from outside users, we welcome questions and contributions.

Install

composer install

Usage

./dev-cleanstart.sh

and

php bin/console

Documentation

There are some general docs on interacting with the codebase as a whole.

Some even broader scoped docs in a seperate repo.

The bundle readme files which show how to interact with the various subsystems.

And not to forget, the all important CHANGELOG.

Tracing

This component comes with a tracing bundle, but it is deactivated by default. To enable it, one must set this ENVs:

TRACING_ENABLED=true

This enables the bundle. Then you need to set the jaeger-bundle specific envs:

AUXMONEY_OPENTRACING_AGENT_HOST=zipkin-hostname # hostname to jaeger
AUXMONEY_OPENTRACING_AGENT_PORT=6831 # port to jaeger
AUXMONEY_OPENTRACING_SAMPLER_VALUE=true # const sampler value (sends always if true or never if false)

See this and this page about the 2 bundles.