PHPackages                             gabrielecorio/fiscozen-wrapper - 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. [API Development](/categories/api)
4. /
5. gabrielecorio/fiscozen-wrapper

ActiveLibrary[API Development](/categories/api)

gabrielecorio/fiscozen-wrapper
==============================

Un wrapper elegante per l'API Fiscozen

v0.0.1(1mo ago)02MITPHPPHP &gt;=8.1

Since Apr 15Pushed 1mo agoCompare

[ Source](https://github.com/GabrieleCorio/fiscozen-wrapper)[ Packagist](https://packagist.org/packages/gabrielecorio/fiscozen-wrapper)[ RSS](/packages/gabrielecorio-fiscozen-wrapper/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

fiscozen-wrapper
================

[](#fiscozen-wrapper)

An unofficial PHP wrapper for the [Fiscozen](https://www.fiscozen.it) web application API.

> **Disclaimer:** This is an unofficial, reverse-engineered client. It is not affiliated with, endorsed by, or supported by Fiscozen. Use at your own risk. The underlying API may change at any time without notice.

---

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- Composer

Installation
------------

[](#installation)

```
composer require gabrielecorio/fiscozen-wrapper
```

Authentication flow
-------------------

[](#authentication-flow)

Fiscozen uses a two-factor authentication flow:

1. Submit credentials → the API sends an OTP to your registered phone number.
2. Submit the OTP → session cookies are persisted to disk for reuse.

The wrapper exposes two approaches depending on your use case.

### Two-step (web application)

[](#two-step-web-application)

Credentials and OTP arrive in separate HTTP requests, so each step is called independently. Session cookies are written to disk between the two calls.

```
use GabrieleCorio\FiscozenWrapper\FiscozenClient;
use GabrieleCorio\FiscozenWrapper\Exceptions\AuthenticationException;

$client = new FiscozenClient(
    email: 'you@example.com',
    password: 'your-password',
    sessionDir: '/path/to/sessions', // optional; defaults to sys_get_temp_dir()/fiscozen_sessions
);

// --- Request 1: submit credentials ---
try {
    $phoneNumber = $client->startLogin(); // returns the masked phone number
    // Store $phoneNumber in your session and show the OTP input to the user
} catch (AuthenticationException $e) {
    // handle error
}

// --- Request 2: submit OTP ---
try {
    $client->submitOtp($otpFromUser);
} catch (AuthenticationException $e) {
    // handle error
}
```

### Single-step (CLI / scripts)

[](#single-step-cli--scripts)

Provide an OTP callback that blocks until the user types the code. The library handles the full flow synchronously. If a valid session already exists on disk it is reused and the callback is never called.

```
$client->login(function (string $phoneNumber): string {
    echo "OTP sent to {$phoneNumber}: ";
    return trim(fgets(STDIN));
});
```

### Checking and destroying a session

[](#checking-and-destroying-a-session)

```
$client->isAuthenticated(); // bool — makes a lightweight API call to verify the session
$client->logout();          // deletes the cookie file and invalidates the local session
$client->relogin($callback); // destroys the existing session and authenticates again
```

Available API methods
---------------------

[](#available-api-methods)

MethodReturnsDescription`getUserMe()``array`Returns the authenticated user's profile data```
use GabrieleCorio\FiscozenWrapper\Exceptions\ApiException;

try {
    $response = $client->getUserMe();
    $user = $response['data'] ?? [];

    echo $user['first_name'] . ' ' . $user['last_name'];
    echo $user['email'];
    echo $user['fiscal_code'];
} catch (ApiException $e) {
    echo "HTTP {$e->getHttpStatusCode()}: {$e->getMessage()}";
}
```

Session persistence
-------------------

[](#session-persistence)

Each user's session is stored in a single JSON file named after the SHA-256 hash of their email address. The directory is created automatically if it does not exist.

```
/tmp/fiscozen_sessions/
└── a3f1...d9.json   ← cookies for you@example.com

```

You can override the directory:

```
$client = new FiscozenClient(
    email: 'you@example.com',
    password: 'your-password',
    sessionDir: __DIR__ . '/sessions',
);
```

Exceptions
----------

[](#exceptions)

ClassExtendsWhen thrown`AuthenticationException``RuntimeException`Login or OTP verification fails`ApiException``RuntimeException`Any non-200 API response; exposes `getHttpStatusCode()``OtpRequiredException``RuntimeException`OTP step is required; exposes `getPhoneNumber()`Full example
------------

[](#full-example)

See [examples/login\_and\_show\_user.php](examples/login_and_show_user.php) for a complete script that:

- checks whether a valid session already exists,
- runs the two-step login flow with terminal OTP input as a fallback,
- calls `getUserMe()` and prints the result.

Running tests
-------------

[](#running-tests)

```
composer install
./vendor/bin/phpunit
```

Project structure
-----------------

[](#project-structure)

```
src/
├── FiscozenClient.php          # Main entry point
├── Api/
│   └── ApiClient.php           # HTTP client for API endpoints
├── Auth/
│   └── AuthManager.php         # Authentication & session management
└── Exceptions/
    ├── ApiException.php
    ├── AuthenticationException.php
    └── OtpRequiredException.php

```

License
-------

[](#license)

This project is released under the MIT License.

###  Health Score

33

—

LowBetter than 73% of packages

Maintenance89

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

55d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6775bd9cb30ca6d3bcc0842178d0ce71172210b7f8352d6b1923d13d6bc96786?d=identicon)[GabrieleCorio](/maintainers/GabrieleCorio)

---

Top Contributors

[![GabrieleCorio](https://avatars.githubusercontent.com/u/21264812?v=4)](https://github.com/GabrieleCorio "GabrieleCorio (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gabrielecorio-fiscozen-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/gabrielecorio-fiscozen-wrapper/health.svg)](https://phpackages.com/packages/gabrielecorio-fiscozen-wrapper)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3751.2M45](/packages/tencentcloud-tencentcloud-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

1.9k496.1k32](/packages/neuron-core-neuron-ai)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.3M7](/packages/avalara-avataxclient)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

232.5k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2478.1k](/packages/filescom-files-php-sdk)[aimeos/prisma

A powerful PHP package for integrating media related Large Language Models (LLMs) into your applications

1772.4k4](/packages/aimeos-prisma)

PHPackages © 2026

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