Download the PHP package pedrokeilerbatistarojo/smartfilter without Composer

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

��# SmartFilter

SmartFilter is a Laravel package designed to provide robust and flexible filtering capabilities for APIs. It allows developers to apply filters, sorting, and pagination to data retrieval seamlessly while returning structured JSON responses.

---

## Installation

1. Require the package via Composer:

`bash

composer require pedrokeilerbatistarojo/smartfilter

`

2. Publish the configuration (optional):

`bash

php artisan vendor:publish --provider="Pedrokeilerbatistarojo\Smartfilter\SmartfilterServiceProvider"

`

3. Usage: Include the package in your controller or service to start applying filters.

---

## Features

- Apply filters with various operators (e.g., like, =, etc.).

- Select specific columns to retrieve.

- Include relationships for eager loading.

- Sort results by any field.

- Paginate results with customizable parameters.

- Structured JSON responses with metadata.

---

## Usage Example

### Sample Request

`http

GET /api/users?filters[0][0]=name&filters[0][1]=like&filters[0][2]=Owner&columns[]=id&columns[]=name&columns[]=email&includes[]=role&sortField=created_at&sortType=asc&itemsPerPage=8&currentPage=1

`

### Query Params

`

filters:[["name", "like", "Owner", "and"],["email", "like","owner@example.com", "and"],["name", "like", "Owner", "and", "role"]]

columns:["id", "name", "email"]

includes:["role"]

sortField:created_at

sortType:asc

itemsPerPage:8

currentPage:1

`

### Controller Example

`php

use Pedrokeilerbatistarojo\Smartfilter\Services\FilterService;

use Pedrokeilerbatistarojo\Smartfilter\Helpers\ResponseHelper;

use Illuminate\Http\Request;

use App\Models\User;

use Exception;

class UserController extends Controller

{

public function construct(

private readonly FilterService $filterService

){

}

/

* @throws Exception

*/

public function invoke(Request $request)

{

try {

$response = $this->filterService->execute(User::class, $request->all());

return ResponseHelper::sendResponse($response);

}

catch(Exception $ex){

return ResponseHelper::sendError($ex->getMessage());

}

}

}

`

### Expected JSON Response

`json

{

"success": true,

"message": "Search completed successfully",

"errors": null,

"payload": {

"items": [

{

"id": 1,

"name": "Owner",

"email": "owner@example.com"

},

{

"id": 2,

"name": "Admin",

"email": "admin@example.com"

}

],

"metadata": {

"currentPage": 1,

"lastPage": 5,

"itemsPerPage": 8,

"total": 40

},

"total": 40

}

}

`

---

## Testing

1. Run the test suite:

`bash

php artisan test

`

2. Example Test:

`php

public function testfilterwith_filters(): void

{

$filters = [

['name', 'like', 'Owner', 'and'],

['email', 'like', 'owner@example.com', 'and'],

['name', 'like', 'Owner', 'and', 'role']

];

$columns = ['id', 'name', 'email'];

$includes = ['role'];

$params = [

'filters' => $filters,

'columns' => $columns,

'includes' => $includes,

'sortField' => 'created_at',

'sortType' => 'asc',

'itemsPerPage' => 8,

'currentPage' => 1

];

$queryString = httpbuildquery($params);

$endpoint = "/api/users?{$queryString}";

$response = $this->get($endpoint);

$response->assertStatus(200);

$response->assertJsonStructure([

'success',

'message',

'errors',

'payload' => [

'items' => [

'*' => [

'id',

'name',

'email'

]

],

'metadata' => [

'currentPage',

'lastPage',

'itemsPerPage',

'total'

],

'total'

]

]);

}

`

---

## Contributing

Feel free to fork this repository and submit pull requests. Ensure that all tests pass and maintain code quality standards.

---

## License

SmartFilter is open-source software licensed under the [MIT License](LICENSE).


All versions of smartfilter with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/database Version ^11.31
illuminate/pagination Version ^11.31
illuminate/http Version ^11.31
illuminate/contracts Version ^11.31
symfony/http-foundation Version ^7.0.3
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 pedrokeilerbatistarojo/smartfilter contains the following files

Loading the files please wait ....