Download the PHP package keloola/quota without Composer

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

Keloola Quota

Package Laravel untuk mengelola billing quota per-app. Mendukung dua tipe quota:

Type Perilaku Contoh
snapshot Quota tetap/fixed. Nilai usage mencerminkan kondisi saat ini, naik-turun mengikuti data, tidak pernah di-reset otomatis. Jumlah user, storage space, jumlah hardware, jumlah ebook
counter Quota yang di-reset setiap bulan (per periode billing). Hanya bertambah sampai reset. Jumlah transaksi, automation run

Terintegrasi dengan model QuotaMetric dan AppPlanQuota dari ERD Pricing & Subscription Anda.

Instalasi

Install via composer:

Publish & jalankan migration:

Migration juga otomatis ter-load lewat loadMigrationsFrom, jadi php artisan migrate bisa langsung jalan tanpa publish.

Konfigurasi referensi tabel

Package tidak memiliki tabel apps, app_plans, dan organizations. Di config/keloola-quota.php atur tipe kolom dan apakah pakai foreign key constraint:

Di setup SSO/distributed (tabel apps ada di service lain), biarkan constrained => false.

Tabel yang dibuat

Penggunaan

Bila config('keloola-quota.strict') true (default), increment yang melewati limit melempar QuotaExceededException:

Context Middleware (Otomatis dari JWT SSO)

Bila aplikasi satelit Anda menerima request dengan Bearer JWT Token dari SSO, Anda dapat menggunakan middleware keloola.quota.context. Middleware ini akan otomatis menembak endpoint SSO (/api/jwt/user), menarik data profil, dan men-set konteks quota (App ID, Organization ID, dan Plan ID) ke Facade.

Pastikan Anda mengatur konfigurasi SSO di .env aplikasi satelit:

Catatan Validasi:

  • Middleware ini secara otomatis memvalidasi token JWT. Jika token kosong atau tidak valid, middleware akan mengembalikan pesan error 401 Unauthorized.
  • Middleware akan mencocokkan KELOOLA_AUTH_APP_ID dengan data applications pada JWT. Jika aplikasi tidak ditemukan atau array aplikasi kosong, akan dikembalikan pesan error 403 Forbidden.

Check Quota Middleware

Selain memanggil Quota::canConsume() secara manual di controller, Anda juga bisa menggunakan middleware keloola.quota.check untuk memblokir request di level route jika kuota tidak mencukupi. Middleware ini menerima parameter berupa metric_code dan opsional amount (default: 1).

Penting: Anda harus meletakkan middleware keloola.quota.context sebelum middleware ini agar konteks kuota sudah disiapkan.

Jika kuota tidak cukup, akan muncul response JSON (429 Too Many Requests). Pesan error akan menyesuaikan bahasa yang diatur pada aplikasi (contoh: config/app.php locale id):

Reset counter bulanan

Jadwalkan command di routes/console.php (Laravel 11+) atau Kernel:

Reset juga terjadi lazy: saat usage counter diakses pada periode baru, period_key otomatis berganti dan nilai mulai dari 0. Command hanya untuk membersihkan/mencatat secara eksplisit.

Plan & Metrik default (QuotaSeeder)

Seeder QuotaSeeder mendefinisikan metrik dan limit untuk 5 app. Sesuaikan map $apps dan $plans dengan id asli di DB Anda, lalu:

App Metrik Type
Accounting Jumlah Transaksi counter
Jumlah User snapshot
Jumlah Invoice, Jurnal counter
Cloud Storage Storage Space (MB), Jumlah File, User snapshot
POS Jumlah Transaksi counter
Jumlah Outlet, Produk snapshot
Ebook Jumlah Ebook snapshot
Automate Jumlah Hardware, User snapshot
Jumlah Automation Run counter

Limit per plan (Basic / Pro / Enterprise) ada di dalam QuotaSeeder; Enterprise umumnya is_unlimited = true.

Provisioning saat instalasi (SSO push)

Alih-alih menjalankan seeder manual di tiap app, SSO dapat mendorong (push) definisi quota ke app saat sebuah organization meng-install app, dan kembali mendorong update saat plan/quota berubah. App menyimpan definisi ini lokal (quota_metrics + app_plan_quotas).

Sisi app (otomatis dari package)

Package mendaftarkan endpoint berikut secara otomatis:

Secara default, endpoint dilindungi middleware keloola.quota.sso (dapat disesuaikan secara dinamis melalui config('keloola-quota.provisioning.middleware')).

Payload yang dikirim SSO

Karena operasinya upsert, payload yang sama aman dikirim berulang — install pertama mengisi, perubahan plan memperbarui. Tidak perlu logika "sudah ada atau belum" di sisi SSO.

Sisi SSO

Contoh dispatcher ada di examples/sso-side/QuotaProvisioningDispatcher.php (bukan bagian package — disalin ke project keloola-sso). Pemicunya:

Bungkus dalam queued job agar tidak memblok request bila app satelit lambat/down.

Catatan: provisioning ini hanya untuk definisi quota (limit per plan). Status subscription aktif/expired tetap dicek terpisah (mis. API call + cache ke SSO), karena status berubah lebih dinamis daripada definisi limit.

Pengecekan Quota Lintas Aplikasi (Cross-App)

Kadang-kadang satu aplikasi (misalnya SSO atau aplikasi lainnya) perlu mengecek limit quota dari aplikasi lain. Package ini menyediakan endpoint bawaan dan service khusus untuk kebutuhan tersebut.

Endpoint Pengecekan Quota

Package ini secara otomatis mengekspos endpoint GET /api/quota/check/{metricCode} yang mengembalikan status penggunaan quota untuk suatu metrik secara langsung (lengkap dengan limit, used, remaining, dan lain-lain).

QuotaCheckService

Untuk melakukan panggilan ke endpoint tersebut dari backend PHP Anda, package ini menyediakan Keloola\Quota\Services\QuotaCheckService. Service ini dapat menangani pemanggilan lintas aplikasi (Cross-App) secara aman dan sudah diregistrasikan sebagai Singleton di Service Provider.

Penggunaan via API URL & Token Dinamis

Pengaturan Konfigurasi Cross-App (Misal: Storage)

Package ini juga mendukung konfigurasi untuk layanan spesifik di config/keloola-quota.php. Anda bisa mengatur api_url dan metric_code via .env.

config/keloola-quota.php:

Penggunaan di Service:


All versions of quota with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^8.2|^8.4
illuminate/support Version ^10.0|^11.0|^12|^13
illuminate/database Version ^10.0|^11.0|^12|^13
illuminate/console Version ^10.0|^11.0|^12|^13
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 keloola/quota contains the following files

Loading the files please wait ...