Download the PHP package rawnoq/laravel-query-api without Composer

On this page you can find all versions of the php package rawnoq/laravel-query-api. 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-query-api

Laravel Query API

Latest Version Total Downloads License

A powerful and elegant Laravel package that brings GraphQL-like flexibility to your REST APIs. Built on top of Spatie Laravel Query Builder, it provides a fluent API for managing complex queries with ease.

Features

Requirements

Installation

Install the package via Composer:

The package will automatically register itself via Laravel's package discovery.

Quick Start

Generate QueryAPI Config Class

The easiest way to get started is to generate a QueryAPI config class using the Artisan command:

This will create a file at app/QueryAPI/UserQueryAPI.php (or modules/{Module}/App/QueryAPI/ for HMVC) with all the basic methods stubbed out.

Basic Usage with Helper Function

Using Config Classes (Recommended)

Create a config class to organize your query settings:

Use the config class in your controller:

Query Parameters

Sorting

Fields (Sparse Fieldsets)

Filters

Partial Filter (LIKE):

Exact Filter:

Operator Filters:

Scope Filters:

Exclusion Filters:

Includes (Relationships)

Pagination

Flexible Pagination Methods:

Complete Example

Available Methods

Core Methods

Filter Types

Exact Filter

Partial Filter (LIKE %value%)

Begins With Filter (LIKE value%)

Ends With Filter (LIKE %value)

Scope Filter

Callback Filter

Operator Filter

Trashed Filter (Soft Deletes)

Exclusion Filters

Include Types

Relationship Include

Count Include

Exists Include

Callback Include

Custom Include

Pagination Configuration

You can configure pagination defaults and limits per model:

Usage:

Advanced Usage

Using with Eloquent Query

Manual Configuration

Using Facade

Virtual Fields

Virtual fields are computed fields or accessors that aren't actual database columns. They can be requested in API calls but won't cause SQL errors.

Defining Virtual Fields

Using in Resources

Helper Methods

The package provides helper methods for checking requested fields and includes:

Performance

The package includes several performance optimizations:

To clear the model table cache (useful for testing):

Security

The package implements a whitelist-based security model:

  1. Fields - Only explicitly allowed fields can be selected
  2. Virtual Fields - Computed fields that are validated but not queried from database
  3. Filters - Only explicitly allowed filters can be applied
  4. Includes - Only explicitly allowed relationships can be loaded
  5. Sorts - Only explicitly allowed fields can be sorted

Any unauthorized request will be silently ignored or throw an exception based on Spatie Query Builder configuration.

Artisan Commands

make:query-api

Generate a new QueryAPI configuration class:

Arguments:

Options:

Examples:

Publishing Stubs

You can publish the command stub for customization:

This will copy the stub file to stubs/query-api.stub in your project root where you can customize it.

Advanced Examples

Edge Cases

Handling Empty Results:

Custom Query with Filters:

Multiple Field Formats:

Virtual Fields with Nested Resources:

Complex Filtering:

Troubleshooting

Common Issues

Issue: "Requested field(s) are not allowed"

Issue: Virtual field causing SQL errors

Issue: Includes not loading

Issue: Model class not found

Issue: Performance with large datasets

Issue: Filter not working

Testing

Changelog

Please see CHANGELOG for more information on recent changes.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Security Vulnerabilities

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-query-api with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^11.0|^12.0
illuminate/http Version ^11.0|^12.0
illuminate/database Version ^11.0|^12.0
spatie/laravel-query-builder Version ^6.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 rawnoq/laravel-query-api contains the following files

Loading the files please wait ...