PHPackages                             railt/railt - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. railt/railt

ActiveLibrary[Framework](/categories/framework)

railt/railt
===========

The Railt GraphQL Framework

1.3.7(7y ago)3592.7k18[16 issues](https://github.com/railt/railt/issues)3MITPHPPHP ^7.1.3

Since Jan 15Pushed 2y ago20 watchersCompare

[ Source](https://github.com/railt/railt)[ Packagist](https://packagist.org/packages/railt/railt)[ Docs](http://railt.org)[ RSS](/packages/railt-railt/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (8)Dependencies (20)Versions (9)Used By (3)

 [![Railt](https://avatars.githubusercontent.com/u/31258828?s=300)](https://railt.org)

 [![PHP 8.1+](https://camo.githubusercontent.com/e6a03c4c2bd8eea15ccaa72fb9c0ab88f3feafe6ecf647f97e097e17b112978c/68747470733a2f2f706f7365722e707567782e6f72672f7261696c742f7261696c742f726571756972652f7068703f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/railt/railt) [![railt.org](https://camo.githubusercontent.com/39377607a50ee86cb989611639e5ceba072723851eea7b88069ed2648647c0a6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d736974652d3666346361352e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d646174613a696d6167652f706e673b6261736536342c6956424f5277304b47676f414141414e5355684555674141414341414141416743414d41414142457049724741414141636c424d564555414141442f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f396557454845414141414a585253546c4d416f427a67386678553969466773766a5177626c795a6451597259523061316f543664716c6b483933546a514e43364e32303031594d774141414d354a524546554f4d764e55746b4f677a414d53337077644d4134426a765a78667a2f7637684f4945417432684d502b4d574e346b525262646f59784d66494d4a536d46737674546d4f413567564a6f4c41446b696771594238716350734e554f56517064326b6b46644134387744653872516b6b574c6a5062416649656473763254317557764b4c552b575957613339484245423252396c574b4931454670685568443551707971584c6f3444546434676e7338756a494136446333472f7843365067676a4a395a5967636e6c32424f4948704d6354474f4b3159342f58425074666263422f7a6170487333793744355064666d4245487867444e4d75524b36624965524473687461583145507353396f577676335146783957767530554141414141456c46546b5375516d4343)](https://railt.org) [![Discord](https://camo.githubusercontent.com/7e29f8f254887b3ce4ba47d02562ac0d3c9b8793ac36a26ad692a3a13b8211d0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646973636f72642d636861742d3666346361352e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d646973636f7264266c6f676f436f6c6f723d666666666666)](https://discord.gg/ND7SpD4) [![Latest Stable Version](https://camo.githubusercontent.com/dc613ee9bbd9a1f9af2e53778b680a6d9beebfd262fa307969bdf8aa68e24283/68747470733a2f2f706f7365722e707567782e6f72672f7261696c742f7261696c742f763f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/railt/railt) [![Total Downloads](https://camo.githubusercontent.com/8c7dbd7de247e691947bfff4da486b43c31ae50cc2042a3d5c46ca006283a7c3/68747470733a2f2f706f7365722e707567782e6f72672f7261696c742f7261696c742f762f756e737461626c653f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/railt/railt) [![License MIT](https://camo.githubusercontent.com/bd564e3665e387aca94d7beae036e9d0b358f1839331ffb5fe53b996fda4ca72/68747470733a2f2f706f7365722e707567782e6f72672f7261696c742f7261696c742f6c6963656e73653f7374796c653d666f722d7468652d6261646765)](https://raw.githubusercontent.com/railt/railt/master/LICENSE.md)

 [![Testing](https://github.com/railt/railt/workflows/tests/badge.svg)](https://github.com/railt/railt/actions?workflow=Testing)

Introduction
------------

[](#introduction)

Project idea is clean and high-quality code.

Unlike most (all at the moment) implementations, like [webonyx](https://github.com/webonyx/graphql-php), [youshido](https://github.com/youshido-php/GraphQL) or [digitalonline](https://github.com/digiaonline/graphql-php)the Railt contains a completely own implementation of the GraphQL SDL parser which is based on [EBNF-like grammar](https://github.com/railt/railt/tree/master/libs/sdl/resources/grammar). This opportunity allows not only to have the [original implementation of the language](https://facebook.github.io/graphql/draft/) and to keep it always up to date, but also to implement [a new backward compatible functionality](https://github.com/railt/railt/projects/1) that is not available to other implementations.

Goal of Railt:

- Do not repeat the mistakes made in the JS-based implementations.
- Implement a modern and convenient environment for PHP developers.
- Implement easy integration into any ready-made solutions based on PSR.
- Provide familiar functionality (including dependency injection, routing, etc.).

Installation
------------

[](#installation)

- `composer require railt/railt`

Quick Start
-----------

[](#quick-start)

This tutorial helps you:

- Obtain a basic understanding of GraphQL principles.
- Define a GraphQL schema that represents the structure of your data set.
- Run an instance of Railt Application that lets you execute queries against your schema.

This tutorial assumes that you are familiar with the command line and PHP and have installed a recent PHP (v8.1+) version.

### Step 1: Create a new project

[](#step-1-create-a-new-project)

1. From your preferred development directory, create a directory for a new project and `cd` into it:

```
mkdir railt-example
cd railt-example
```

2. Initialize a new project with Composer:

```
composer init
composer require railt/railt dev-master@dev
```

> Your project directory now contains a `composer.json` file.

> Please note that in case of installation errors related to installing the dev version (*"The package is not available in a stable-enough version according to your minimum-stability setting"*), you need to specify `"minimum-stability": "dev"` in `composer.json` file.
>
> See more at

Applications that run Railt Application may require two top-level dependencies:

- `railt/webonyx-executor` - An executor that provides a [webonyx/graphql-php](https://github.com/webonyx/graphql-php) bridge for launching and processing GraphQL requests.
- `railt/router-extension` - A router extension that provides a convenient way to delegate GraphQL requests to controller instances.

> Alternatively, you can install all components separately:
>
> ```
> composer require railt/factory railt/webonyx-executor railt/router-extension
> ```

### Step 2: Define your GraphQL schema

[](#step-2-define-your-graphql-schema)

Every GraphQL application (including Railt) uses a schema to define the structure of data that clients can query. In this example, we'll create an application for querying a collection of users by `id` and `name`.

Open `index.graphqls` in your preferred code editor and paste the following into it:

```
# Comments in GraphQL strings (such as this one)
# start with the hash (#) symbol.

# This "User" type defines the queryable fields for
# every user in our data source.
type User {
    id: ID
    name: String
}

# The "Query" type is special: it lists all of the
# available queries that clients can execute, along with
# the return type for each. In this case, the "books"
# query returns an array of zero or more Books (defined above).
type Query {
    users: [User]
}
```

Now just open (create) the `index.php` file and paste the following into it:

```
