Download the PHP package hibernator/hibernator-phplib without Composer

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

Hibernator 💤

Write PHP code that sleeps for months, survives server crashes, and wakes up exactly where it left off.

Hibernator is a Durable Execution Engine for PHP 8.2+. It eliminates the complexity of queues, cron jobs, and state machines by allowing you to write long-running business processes as simple, linear code.

🌟 The Problem: "Cron & Queue Spaghetti"

Modern applications are full of multi-step processes that span hours, days, or even months:

Traditionally, you implement this by fragmenting your logic into:

  1. Database Columns: status = 'WAITING_FOR_EMAIL', next_check = '2025-01-01'.
  2. Cron Jobs: Scripts that poll the DB every minute: SELECT * FROM users WHERE next_check < NOW().
  3. Queue Workers: Jobs that handle one tiny slice of logic and then dispatch the next job.

The result? Your business logic is scattered across 10 different files, 3 different infrastructure pieces, and it's impossible to read the flow of the program.

⚡ The Solution: Hibernator

Hibernator lets you write the entire flow in one single PHP file.

How is this possible?

Hibernator uses PHP Fibers to suspend execution and the Replay Pattern (Event Sourcing) to restore state.

  1. When you yield wait, Hibernator saves your execution history to the database and kills the process. Zero resources are used.
  2. When the time is up, a Worker boots up the workflow.
  3. It replays previous steps instantly from the database history (skipping the actual work) to restore variables and memory state.
  4. It continues executing from the exact line where it left off.

📋 Requirements

📦 Installation

Install via Composer:


🚀 Quick Start Guide

Step 1: Database Setup

You need to create the tables to store standard workflow state and event history. Run the following SQL in your database:

Step 2: Create an Activity

Activities are the building blocks of your workflow. They represent side effects (e.g., sending an email, charging a card, writing to a file). They must implement Hibernator\Activity\ActivityInterface.

Important: Activities should be idempotent if possible, as they might be retried in failure scenarios (though the Replay Pattern generally prevents re-execution of successful activities).

Step 3: Create a Workflow

Workflows define the flow of logic. They are deterministic code that orchestrates your activities.

Step 4: Run a Workflow (The Orchestrator)

To start a new workflow, you need the Orchestrator. This is the engine that manages the Fibers.

Step 5: Run the Worker (The "Heartbeat")

When a workflow sleeps (e.g., wait('3 days')), it saves its state to the database and stops executing. To wake it up when the time comes, you need a Worker process running in the background.

Run this script in a supervisor process or a terminal:


📚 API Reference

Hibernator\Workflow\WorkflowContext

The static API used inside your Workflow classes.

execute(ActivityInterface $activity): mixed

Yields execution to the orchestrator to run an activity.

wait(string $duration): void

Pauses the workflow for a specified duration.

sideEffect(callable $callable): mixed

Executes a non-deterministic snippet of code (like generating a random ID) and checkpoints the result so it is deterministic on replay.


⚙️ How It Works (Under the Hood)

Hibernator uses the Event Sourcing / Replay Pattern.

  1. Run 1: You start the workflow. It runs until it hits an Activity. It executes the Activity, saves the result to the history table, and continues.
  2. Sleep: It hits a wait() command. It saves a "timer started" state and updates the workflow status to sleeping. The PHP process exits.
  3. Wake Up: The Worker sees the wake_up_time has passed. It calls Orchestrator->run().
  4. Replay: The workflow starts from the beginning.
    • It hits the first Activity. It sees in history that it's already done. It skips execution and returns the saved result.
    • It hits the wait(). It sees the timer is done. It continues.
    • It executes the next step (new code).

Testing

Hibernator is designed for testing. You can easily test 7-day workflows in 1 second by mocking time.

See tests/TimeSkippingTest.php in the repository for a full example of how to use a fake time source to verify your long-running logic instantly.

License

MIT License. Free to use for personal and commercial projects.


All versions of hibernator-phplib with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-pdo Version *
ext-json Version *
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 hibernator/hibernator-phplib contains the following files

Loading the files please wait ...