Download the PHP package gregorip02/restql without Composer

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

RestQL

Actions Status

RestQL is a Laravel eloquent-based data resolution package. This package tries to adopt GraphQL principles solving only the data that the client requests. RestQL uses your Laravel models as an entry point to add queries to then based in the eloquent methods.

Please see the documentation.

Why?

Imagine you have an application that manages authors, these authors can publish articles and those articles can have comments from different authors. You have a web client, for example, that uses fetch to consume the data offered by your service and somewhere in your code, you need a list of the author's names only.

They wear something like that.

So, you have a route like this.

routes/api.php

Most likely you will use a controller, then use the author model and query the data. Finally you would have a response similar to this.

But what if you only need a author's names collection for example? Imagine that your application becomes huge and your user model handles a large number of attributes.

Get started

Install RestQL using composer.

Publish the package configuration.

Add the RestqlAttributes trait to your eloquent models.

2.2 This is recomended because you can determine the selectable attributes with onSelectFillable.

Generate an authorizer for your App\Models\Author model.

This creates a new class in the namespace App\Restql\Authorizers\AuthorAuthorizer like the following.

Then add the available HTTP methods to your authorizer as follows.

Then, set your schema definition.

Since version 2.x of this package the configuration has been updated to increase flexibility and internal behavior modification.

You must define your entire schema in the config file, RestQL will then interpret it and execute the queries based on this file. With this there is a possibility that you can remove internal functions, modify them or even create your own implementations. See Schema definition.

config/restql.php

The developer must specify the return type of the relationships defined in the eloquent model. You should set the return type of your associative methods (relationships). For example.

app/Models/Author.php

Configure your endpoint.

routes/api.php

Refactor time

Now, you can re-factor your client's code so that it sends a parameter in the request with the data it needs, in this case a collection of author names. They wear something like that.

The parameters of the query should be a parsed objects that defines the clauses accepted by your schema definition. For your web clients we recommend qs. Instead of having a long JSON response with unnecessary data, you would get something like this.

Likewise, this will considerably optimize your queries to the database management system. In this case, it will run just a select id, name from authors for example.

The good parts

So, let's say you now have a requirement in your application that tells you to have the id and title of the last two articles published by each author.

You wold get a response like this.

How it works

Basically, RestQL filters the keys of the models received in the HTTP request and compares them with the keys of the user configuration. These keys represent a specific eloquent model. The values of these keys are eloquent clauses (methods) accepted by RestQL and the arguments of these clauses are sent as values.

For example, if a params like the following is sent in the request.

RestQL will interpret this as the following.

You can read more about the RestQL Clausules <a href="https://github.com/gregorip02/restql/wiki/Clausules" title="RestQL Documentation">here.

What's next?

Are you interested on contrib to this project? see the <a href="./NEXT.md" title="Next features">NEXT.md file.

Contributing

Thanks for consider contrib to this project, please see the development docs at this page.

Please support it

This is a personal project that can be very useful, if you believe it, help me develop new functionalities and create a pull request, I will be happy to review and add it. So, You can also contribute to the team by buying a coffee.

<img src="https://cdn.buymeacoffee.com/buttons/default-red.png" style="border-radius: 5px;" alt="Buy Us A Coffee" width="300" height="80"/>


All versions of restql with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1|^8.0
laravel/framework Version ^5.8|^6.2|^7.3|^8.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 gregorip02/restql contains the following files

Loading the files please wait ....