devmoath / jql-builder
JQL builder is a supercharged PHP package that allows you to create Jira Query Language (JQL)
Installs: 3 793
Dependents: 1
Suggesters: 0
Security: 0
Stars: 17
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: ^8.0
- spatie/macroable: ^2.0
Requires (Dev)
- laravel/pint: ^1.2.0
- nunomaduro/collision: ^6.0
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.0
- pestphp/pest-plugin-laravel: ^1.3
- phpstan/extension-installer: ^1.2
- phpstan/phpstan: ^1.8.6
- phpstan/phpstan-strict-rules: ^1.4
- rector/rector: ^0.15.0
- symfony/var-dumper: ^6.0.0
README
JQL builder is a supercharged PHP package that allows you to create Jira Query Language (JQL).
Get Started
Requires PHP 8.0+
First, install devmoath/jql-builder
via the Composer package manager:
composer require devmoath/jql-builder
Then, interact with JQL builder:
$query = new Jql(); $query->where('project', 'PROJECT')->where('summary', '~', 'title'); echo $query; // 'project = "PROJECT" and summary ~ "title"'
Usage
This is how to generate query:
use JqlBuilder\Jql; $builder = new Jql(); // Simple query $query = $builder->where('project', 'MY PROJECT')->getQuery(); echo $query; // 'project = "MY PROJECT"' $builder = new Jql(); // Complex query $query = $builder->where('project', 'MY PROJECT') ->where('status', ['New', 'Done']) ->orWhere('summary', '~', 'sub-issue for "TES-xxx"') ->orWhere('labels', 'support') ->when(false, fn (Jql $builder, mixed $value) => $builder->where('creator', 'admin')) ->when(true, fn (Jql $builder, mixed $value) => $builder->where('creator', 'guest')) ->orderBy('created', 'asc') ->getQuery(); echo $query; // 'project = "MY PROJECT" and status in ("New", "Done") or summary ~ "sub-issue for \"TES-xxx\"" or labels = "support" and creator = "guest" order by created asc'
Also, you can add macro functions as well to encapsulate your logic:
use JqlBuilder\Jql; $builder = new Jql(); $builder::macro('whereCustom', function (mixed $value) { /* * your code... */ /** @var Jql $this */ return $this->where('custom', $value); }); $query = $builder->whereCustom('1')->getQuery(); echo $query; // 'custom = "1"'
laravel facade support out of the box:
use JqlBuilder\Facades\Jql; $query = Jql::where('summary', '=', 'value')->getQuery(); echo $query; // 'summary = "value"'
Contributing
Thank you for considering contributing to the JQL Builder! The contribution guide can be found in the CONTRIBUTING.
Security Vulnerabilities
If you discover any security-related issues, please email moath.alhajrii@gmail.com instead of using the issue tracker.
License
JQL builder is an open-sourced software licensed under the MIT license.