38

GitHub - railt/railt: A PHP GraphQL Framework

 5 years ago
source link: https://github.com/railt/railt
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

Railt

Travis CI Code coverage Scrutinizer CI Latest Stable Version Latest Unstable Version License MIT

Introduction

This is a pure PHP realization of the GraphQL protocol based on the webonyx/graphql-php implementations of the official GraphQL Specification located on Facebook GitHub.

The difference from the above implementations is that the Railt provides the ability to describe the types and extended control of their behavior, thereby solving problems such as:

  • Simplifying type declarations
  • Types reusage
  • Significant simplification of the construction of the API
  • More flexible integration with frameworks (e.g. Laravel or Symfony)
  • And others

Installation

  • Add into your composer.json:
{
    "scripts": {
        "post-autoload-dump": [
            "Railt\\Discovery\\Manifest::discover"
        ]
    }
}
  • composer require railt/railt

Quick start

The documentation is in the process of writing, therefore, in order to understand how it works, a quick start.

schema.graphqls

This is our main GraphQL application schema.

schema {
    query: Example
}

type Example {
    say(message: String = "Hello"): String! 
        @route(action: "ExampleController@say")
}

ExampleController.php

The GraphQL request query { say } handler indicated in the @route directive

class ExampleController
{
    public function say(string $message): string
    {
        return $message;
    }
}

index.php

This is the main file that handles all requests to the application. With the same success this role can be performed by any controller in the MVP (MVC with passive models) application, for example on the basis of a Symfony or Laravel.

<?php
use Railt\Io\File;
use Railt\Discovery\Discovery;
use Railt\Foundation\Application;
use Railt\Foundation\Config\Composer;
use Railt\Http\Provider\GlobalsProvider;


$loader = require __DIR__ . '/vendor/autoload.php';

//
// Creating a new Application
//
$app = new Application();

//
// Configure an Application from "composer.json" file
//
$app->configure(new Composer(Discovery::fromClassLoader($loader)));

//
// Create a connection
//
$connection = $app->connect(File::fromPathname(__DIR__ . '/schema.graphqls'));

//
// Processing of HTTP Request
//
$responses = $connection->requests(new GlobalsProvider());

//
// And send the HTTP Response
//
$responses->send();

Response:

{
    "say": "Something is awesome!"
}

Learning Railt

This documentation can contain NOT RELEVANT information and currently in progress.

Contributing

Thank you for considering contributing to the Railt Framework! The contribution guide can be found in the documentation.

Security Vulnerabilities

If you discover a security vulnerability within Railt, please send an e-mail to maintainer at [email protected]. All security vulnerabilities will be promptly addressed.

License

The Railt Framework is open-sourced software licensed under the MIT license.

The Railt\Compiler, which is part of the Railt Framework re-distribute under the BSD-3-Clause license.

FOSSA Status

Development Status

Packages Release CI Status railt/railt Latest Stable Version Travis CI railt/compiler Latest Stable Version Travis CI railt/discovery Latest Stable Version Travis CI railt/laravel-provider Latest Stable Version Travis CI railt/symfony-bundle Latest Stable Version Travis CI Components Release CI Status railt/container Latest Stable Version Travis CI railt/http Latest Stable Version Travis CI railt/io Latest Stable Version Travis CI railt/sdl Latest Stable Version Travis CI railt/storage Latest Stable Version Travis CI railt/lexer Latest Stable Version Travis CI railt/parser Latest Stable Version Travis CI

Supported By

JetBrains Rambler&Co


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK