Download the PHP package scriptle/laragraph without Composer

On this page you can find all versions of the php package scriptle/laragraph. 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 laragraph

LaraGraph

[WIP] An elegant wrapper to webonyx/graphql-php that uses PHP 8 attributes.

Installation

Requirements: PHP 8

composer require scriptle/laragraph

Usage

Publish the config file:

php artisan vendor:publish --provider=Scriptle\\Laragraph\\LaragraphServiceProvider

Amend the schemas to your preference.

Folder Structure

app/Models is also traversed for models with GraphQL Type attributes present.

Schema

Schemas are defined in config/laragraph.php under the schemas key.

The prefix (gql) is prepended to all schemas. The schema key is the URL. So for v1, the full URL is /gql/v1.

Within the schema key you define your GraphQL schema as usual, referencing the root types by string.

You can add custom middleware with that key, such as an entire schema limited to admin users.

Then, you must add your root types as you defined them, like so:

Attributes

On the class, add the following attribute:

#[Type] on its own will use the class name as the GraphQL type name.

#[Type('Person')] will use Person as the GraphQL type name.

#[Type('User', 'A user in the database.')] will use User as the GraphQL type name, plus a GraphQL introspection descriptor for this type.

Defining Fields

To define simple fields returned through Eloquent, you can simply attach them with the Type attribute:

Note: Eloquent relationships are automatically supported this way.

Fields with a custom resolver

If your field is not database-based, or needs to be passed through a callback you can use this feature.

EITHER:

Format: resolve + (StudlyCase) LastName + Field = resolveLastNameField

OR

Function can be named anything as long as it has the ResolvesFor attribute. This hooks in nicely with Laravel's custom getters.

OR LASTLY:

Move the Field attribute down to the function instead, if you prefer this style.

Argument-ed Fields

Some fields, especially in queries, need arguments. The syntax is direct GraphQL definition syntax:

#[Field('lookupUser("User ID" id: String!)', 'User', 'Look up a user by ID.')]

This defines a lookupUser field with 1 argument, id of type String! (with ! so it must be non-null) and with introspection description of User ID.

The same can be done for mutations or querying fields on types.

Custom Types

Custom Types can be defined like the User model above, and can be placed in the app/GraphQL/Types folder to keep them separate from your models. This is useful for mutation responses, or other complex response structures.

Types are referenced by their type name (as registered by the #[Type] attribute), just with regular GraphQL. There is no need to create a variable or reference classes directly!

Caching

The config/laragraph.php will be cached along with Laravel's regular config caching (php artisan config:cache || php artisan config:clear)

You can also cache Laragraph's Type mappings to avoid processing these on each request. Use php artisan gql:cache to cache, and php artisan gql:clear to remove.


All versions of laragraph with dependencies

PHP Build Version
Package Version
Requires webonyx/graphql-php Version ^14.5
php Version ^8.0
ext-json Version *
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 scriptle/laragraph contains the following files

Loading the files please wait ....