PHPackages                             sevaske/zatca - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sevaske/zatca

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sevaske/zatca
=============

Zatca laravel library

v1.1.0(8mo ago)13514↑83.3%3[2 PRs](https://github.com/sevaske/zatca/pulls)MITPHPPHP ^8.1CI passing

Since Jul 21Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/sevaske/zatca)[ Packagist](https://packagist.org/packages/sevaske/zatca)[ Docs](https://github.com/sevaske/zatca)[ GitHub Sponsors](https://github.com/sevaske)[ RSS](/packages/sevaske-zatca/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (13)Versions (8)Used By (0)

Laravel Integration for ZATCA e-Invoicing
=========================================

[](#laravel-integration-for-zatca-e-invoicing)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bc962978f91abb3ab067f7154c676172c00873fed8e554b90696edb8e698e250/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73657661736b652f7a617463612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sevaske/zatca)[![Total Downloads](https://camo.githubusercontent.com/82dfe6a067b9a25dd316f546537b9b3c0cdc1639228880d26649f00828ef01ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73657661736b652f7a617463612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sevaske/zatca)

**Zatca** is a Laravel package that integrates with the [ZATCA e-invoicing system](https://zatca.gov.sa/), wrapping the [php-zatca-xml](https://github.com/sevaske/php-zatca-xml) core for certificate generation, XML invoice signing, and submission to the ZATCA API — all the Laravel way.

🧱 Under the Hood
----------------

[](#-under-the-hood)

This package is a Laravel wrapper around:

- [sevaske/php-zatca-xml](https://github.com/sevaske/php-zatca-xml) – core logic for XML building and signing
- [sevaske/zatca-api](https://github.com/sevaske/zatca-api) – ZATCA API client

✨ Features
----------

[](#-features)

- 🧾 Generate and sign e-invoices (XML + QR)
- 🔐 Manage CSRs, private keys, credentials
- 🌍 Sandbox, simulation &amp; production environments
- 📂 Uses Laravel's filesystem to store certs and invoices
- ⚙️ Laravel service provider, config, macros and bindings
- 📦 Clean and extendable codebase

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require sevaske/zatca
```

Install

```
php artisan zatca:install
```

🚀 Quick Start
-------------

[](#-quick-start)

Run the following commands in sequence to set up your certificates and get started:

```
php artisan zatca:generate-csr
php artisan zatca:compliance-certificate
php artisan zatca:production-certificate
```

⚙️ Configuration
----------------

[](#️-configuration)

```
return [
    'env' => env('ZATCA_ENV', 'sandbox'),
    'storage' => [
        'credentials_disk' => env('ZATCA_CREDENTIALS_DISK', env('FILESYSTEM_DISK', 'local')),
        'invoices_disk' => env('ZATCA_INVOICES_DISK', env('FILESYSTEM_DISK', 'local')),
        'paths' => [
            'invoices' => env('ZATCA_INVOICES_FOLDER_PATH', 'zatca/invoices'),
            'csr' => env('ZATCA_CSR_PATH', 'zatca/certificate.csr'),
            'private_key' => env('ZATCA_PRIVATE_KEY_PATH', 'zatca/private_key.pem'),
            'compliance_credentials' => env('ZATCA_COMPLIANCE_CREDENTIALS_PATH', 'zatca/compliance_credentials.json'),
            'production_credentials' => env('ZATCA_PRODUCTION_CREDENTIALS_PATH', 'zatca/production_credentials.json'),
        ],
    ],
];
```

✅ Usage
-------

[](#-usage)

Available commands

```
php artisan zatca:generate-csr
php artisan zatca:compliance-certificate
php artisan zatca:production-certificate
```

XML Generation and Signing
--------------------------

[](#xml-generation-and-signing)

This library uses [php-zatca-xml](https://github.com/sevaske/php-zatca-xml) for generating and signing XML files.
More details:

### API Methods

[](#api-methods)

The `\Zatca::api()` method is a wrapper around the [sevaske/zatca-api](https://github.com/sevaske/zatca-api) package, providing a simplified interface for interacting with ZATCA services:

```
use Illuminate\Support\Str;

// Reporting Invoice
\Zatca::api()->reporting('signed xml', 'hash', Str::uuid());

// Clearance Invoice
\Zatca::api()->clearance('signed xml', 'hash', Str::uuid());

// Compliance Check
\Zatca::api()->compliance('signed xml', 'hash', Str::uuid());

// Compliance Certificate Request
\Zatca::api()->complianceCertificate('csr', 'otp');

// Production Certificate Request
\Zatca::api()->productionCertificate('complianceRequestId');
```

More details:

### File Access Helpers

[](#file-access-helpers)

The `\Zatca::files()` method provides access to stored production credentials:

```
// Get the production certificate
\Zatca::files()->productionCredentials()->certificate();

// Get the secret associated with the certificate
\Zatca::files()->productionCredentials()->secret();

// Get the request ID used for the certificate
\Zatca::files()->productionCredentials()->requestId();
```

🔌 HTTP Macro
------------

[](#-http-macro)

```
use Illuminate\Support\Facades\Http;

Http::zatca(); // \Sevaske\ZatcaApi\Api
```

🧩 Zatca Macro
-------------

[](#-zatca-macro)

The main `Zatca` class uses Laravel’s `Macroable` trait, allowing you to define your own methods at runtime:

```
use Sevaske\Zatca\Facades\Zatca;

Zatca::macro('hello', function () {
    return '👋 Hello from macro!';
});

Zatca::hello(); // "👋 Hello from macro!"
```

You can register macros in a service provider or any bootstrap code (like `AppServiceProvider`).

🧪 Testing
---------

[](#-testing)

```
composer test
```

📜 Changelog
-----------

[](#-changelog)

See [CHANGELOG.md](CHANGELOG.md) for recent changes.

⚖ License
---------

[](#-license)

MIT. See [LICENSE](LICENSE) for details.

🙌 Credits
---------

[](#-credits)

Made by [Sevaske](https://github.com/sevaske)

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance76

Regular maintenance activity

Popularity26

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~7 days

Total

5

Last Release

265d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/94643c38672a39a9b675ab6d43f5c1d3c0789300cc052f742a960e0a7d70847e?d=identicon)[sevaske](/maintainers/sevaske)

---

Top Contributors

[![sevaske](https://avatars.githubusercontent.com/u/42838184?v=4)](https://github.com/sevaske "sevaske (35 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

laravelZATCAfatoorasevaske

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/sevaske-zatca/health.svg)

```
[![Health](https://phpackages.com/badges/sevaske-zatca/health.svg)](https://phpackages.com/packages/sevaske-zatca)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M626](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
