Download the PHP package hmennen90/laravel-graphql without Composer

On this page you can find all versions of the php package hmennen90/laravel-graphql. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-graphql

laravel-graphql

CI Latest Version PHP Version Total Downloads

A hand-written GraphQL engine with first-class Laravel integration — no dependency on webonyx/graphql-php. Define your schema code-first (PHP), schema-first (SDL), attribute-driven, or mix all three; they compile to one internal schema.

Status: in active development. APIs may change before the first stable release.

Key differentiator — single source of truth

Unlike SDL-first stacks, you do not implement a type twice. There is no SDL type mirroring your Eloquent model plus a separate type/transformer class, and no directive DSL to keep in sync. Declare a type once; resolvers are plain PHP callables that read your models directly.

Features

Requirements

Installation

Publish the config (and optionally a starter schema):


Quick start (Laravel)

Create a schema provider:

Register it in config/graphql.php:

Query the endpoint:


Defining a schema

Code-first

Recursive/cyclic types are fine — pass a closure for lazily-resolved fields:

Schema-first (SDL)

Fields without a resolver fall back to reading array keys, object properties or getters.

Attribute-driven

SDL type extensions


Eloquent directives (CRUD without resolvers)

Build a full CRUD API over Eloquent declaratively — the model stays the single source of truth, and directives derive queries, columns and relations from it.

Everything is also available as PHP attributes that dispatch to the exact same implementations — pick SDL or code-first per taste, with no duplicated logic:

Reading (@all/@find/@first/@paginate), relations (@hasMany/@hasOne/@belongsTo/@belongsToMany/@morph*/@count), filtering & sorting (@whereConditions/@orderBy), mutations incl. nested (@create/@update/@delete/@upsert), auth/utility (@guard/@inject/@field/@rename) and Laravel Scout (@search) are all supported. See Eloquent directives for the full reference.

Apollo Federation

Expose any schema as a federated subgraph:

This adds _service { sdl }, _entities(representations:) and the _Any/_Service/ _Entity types, wiring one reference resolver per entity type. See Apollo Federation.


Generating types from your Laravel app

The strongest form of "single source of truth": derive GraphQL types from the artifacts you already maintain — Eloquent models, FormRequest rules and JSON responses — instead of re-declaring their shape.

Compose the generated types into a schema like any hand-built type:

Mapping notes: model casts and rule tokens map to the built-in scalars; array/json casts and array rules use a bundled JSON scalar. Nested resource arrays become nested object types. Generators produce a starting point you can refine — add relations, hide fields, or wrap the returned types as needed.


Executing standalone (without Laravel)

The engine has no framework dependency:

Or validate first:


Laravel integration

Configuration

config/graphql.php controls the endpoint, GraphiQL, schema source, batching, error handling, security limits, persisted queries, cache-control and subscriptions.

Artisan commands

The GraphQL facade

Authorization

Inside a resolver, use the request Context:

Or declaratively in SDL with the @can directive:

Argument validation

Use Laravel's validator inside a resolver; a thrown ValidationException surfaces under errors[].extensions.validation:

Or declaratively in SDL with the built-in directives — @rules validates a single argument, @validator binds a dedicated validator class, and the sanitisers run before the resolver:

See Validation & argument sanitisers for the full reference.

Error masking

With graphql.debug = false, internal exception messages are masked to "Internal server error". Client-safe exceptions (authorization, authentication, validation) pass through and are categorised under extensions.category.

File uploads

Add the Upload scalar and send a GraphQL multipart request:

Uploaded files arrive as Illuminate\Http\UploadedFile instances.

Automatic Persisted Queries (APQ)

Clients send extensions.persistedQuery.sha256Hash; the first request registers the query, later requests may send the hash alone.

HTTP caching (@cacheControl)

The endpoint emits a Cache-Control header from the minimum maxAge of the selected fields. Combined with APQ (GET + hash), this enables CDN/HTTP caching.

Subscriptions

Enable and broadcast events:

Clients subscribe via Laravel Echo (broadcasting) or a graphql-ws client. To run the bundled graphql-ws server (requires the Swoole extension):


Performance

DataLoader (N+1 batching)

All companies requested during one query are fetched in a single batch call.

Query limits

Benchmarks

A dependency-free harness measures each phase (parse/build/validate/execute), list throughput and DataLoader batching:

Indicative results on an Apple Silicon laptop, PHP 8.4 (no JIT) — median over many iterations. Numbers are machine-specific; the shape (per-phase cost, scaling) is what matters:

Scenario Median Throughput
parse: small query ~6 µs ~165k/s
parse: nested query ~25 µs ~40k/s
build: schema from SDL ~100 µs ~10k/s
validate: nested query ~7 µs ~142k/s
execute: flat field ~2 µs ~470k/s
execute: list of 100 ~0.64 ms ~1,560/s
execute: list of 1000 ~6.4 ms ~157/s
execute: 500 nested + DataLoader ~7.8 ms ~130/s
full: parse+validate+execute (100) ~0.68 ms ~1,470/s

Parse, validate and small executions run in microseconds; list execution scales linearly (~3.8 µs/object) after the executor completes synchronous fields inline. In an engine-to-engine comparison this beats webonyx/graphql-php (Lighthouse's engine) across every scenario, and end-to-end (Laravel + Eloquent) it resolves ~1.5× faster than Lighthouse. See Benchmarks.


Custom directives

Runtime (query) directive — wrap field resolution:

Build-time SDL directives implement SchemaDirective and are passed to SchemaBuilder::fromSdl(..., schemaDirectives: [...]) (see @can/@cacheControl).

Relay pagination

Introspection & GraphiQL

Full introspection is supported. With graphql.graphiql.enabled = true, an in-browser IDE is served at /graphiql.


Testing

Contributing

Contributions are welcome — see CONTRIBUTING.md. Commits follow Conventional Commits; releases are cut with semantic-release. Please also read the Code of Conduct.

Security

Please report security issues privately — see SECURITY.md.

Changelog

See CHANGELOG.md (generated by semantic-release).

Comparison

A full, per-package feature comparison (vs. Lighthouse, rebing/graphql-laravel, webonyx/graphql-php) is in the documentation.

Migrating from Lighthouse

Not a drop-in replacement, but a realistic migration: the CRUD, relation, filter/sort (incl. single-field @eq/@like/@scope/@limit…), soft-delete and auth directive names and semantics were kept compatible, and convention-resolved query/mutation classes carry over (graphql.namespaces). Run php artisan graphql:lint to get a precise list of anything unsupported (e.g. @builder, @with, subscriptions), and use the MakesGraphQLRequests test trait so existing feature tests keep working. See the full migration guide.

License

MIT — see LICENSE.


All versions of laravel-graphql with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
illuminate/contracts Version ^11.0 || ^12.0 || ^13.0
illuminate/database Version ^11.0 || ^12.0 || ^13.0
illuminate/pagination Version ^11.0 || ^12.0 || ^13.0
illuminate/support Version ^11.0 || ^12.0 || ^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hmennen90/laravel-graphql contains the following files

Loading the files please wait ...