Download the PHP package devespresso/system-life-cycle without Composer

On this page you can find all versions of the php package devespresso/system-life-cycle. 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 system-life-cycle

Laravel Life Cycle System

A Laravel package for managing multi-stage, queue-driven lifecycle workflows on Eloquent models. Define workflows with ordered stages, attach them to any model, and let the system execute, retry, and log every transition automatically.

Requirements

Installation

Publish the config and migrations:

Configuration

Important: Set model_id_type before running migrations. It controls the column type used for model_id in the system_life_cycle_models and system_life_cycle_logs tables and cannot be changed after migration without a manual schema change.

Core Concepts

Lifecycle

A SystemLifeCycle is the workflow definition. It has a unique code, an active flag, date range, and an ordered set of stages.

Stage

A SystemLifeCycleStage belongs to a lifecycle and holds the sequence (order) and the fully-qualified class name of the service that executes it.

Lifecycle Model

A SystemLifeCycleModel is the per-model record that tracks where a specific Eloquent model is in a specific lifecycle — current stage, status, attempts, payload, and scheduling.

Lifecycle Log

A SystemLifeCycleLog records every execution attempt (success or failure) with the stage, status, payload snapshot, and any error message.

Statuses

Status Meaning
pending Waiting to be picked up
processing Claimed by the current run batch
completed All stages finished successfully
failed Exceeded max attempts
success Used in logs to mark a successful execution

Usage

1. Enable lifecycles on a model

Add the EnableSystemLifeCycles trait to any Eloquent model:

This provides the following methods:

2. Create a stage service

Extend SystemLifeCycleService for each stage in your workflow:

Available helpers in your stage:

Helper Description
$this->model The Eloquent model attached to this lifecycle record
$this->params The payload array (persisted across stages)
$this->systemLifeCycleModel The SystemLifeCycleModel record
$this->setParam(key, value) Write a value into the payload
$this->getParam(key) Read a value from the payload
$this->isRetry() Returns true if this is a retry attempt (attempts >= 1)
$this->setExecutesAt() Override to return a Carbon instance for deferred rescheduling

3. Register the lifecycle

Use the interactive Artisan command to create a lifecycle and its stages:

Or create them programmatically:

4. Attach models to the lifecycle

5. Automatic scheduling

The package automatically registers the following scheduled commands via its service provider:

Command Default Frequency
devespresso:life-cycle:run Hourly
devespresso:life-cycle:logs-clean-up Weekly
devespresso:life-cycle:completed-models-clean-up Weekly

You can customize frequencies or disable auto-scheduling entirely via the schedule config key:

The run command:

  1. Resets stale executes_at values (older than stale_after_minutes, default 120)
  2. Assigns the first stage to any records missing one
  3. Claims all pending records as processing using a batch ID
  4. Dispatches a SystemLifeCycleExecuteJob for each claimed record

Execution window (whereCanBeExecuted scope)

The whereCanBeExecuted scope determines which records are eligible on each tick. A record is eligible when:

  1. Its lifecycle is active and has started (and not ended)
  2. If running via cron, the lifecycle has activate_by_cron = true
  3. Either executes_at is null (run immediately) or it falls within the configured window

The window is controlled by schedule.run.window_in_minutes (default 60) and extends in both directions from now(). Boundaries are snapped to startOfMinute() / endOfMinute() so records scheduled at any second within those boundary minutes are included.

When customizing the run frequency, keep all three values in sync:

Frequency window_in_minutes stale_after_minutes
everyFiveMinutes 5 10
everyTenMinutes 10 20
hourly (default) 60 120

You can also pass custom $startDate / $endDate arguments to the scope to override the config window entirely.

Execution Flow

On exception:

With max_attempts = 3, a record gets exactly 3 total execution attempts before being marked as failed.

Stage Payload

The payload column is a JSON object shared across all stages of a lifecycle run. Use setParam and getParam to pass data between stages without extra queries:

Deferred Execution

Return a specific time from setExecutesAt() to control when a rescheduled stage runs:

Re-enrollment

To restart a completed (or failed) lifecycle from the beginning:

This resets the record to stage 1 with status=pending, attempts=0, and clears payload, batch, and executes_at. If the model was never enrolled it creates a fresh record, making it safe to call unconditionally.

Retry Behaviour

When shouldContinueToNextStage() returns false on the first attempt, the stage is rescheduled silently (no log). On subsequent attempts (isRetry() === true) the stage runs regardless, so a model is never permanently stuck waiting.

Custom Model ID Types

If your models use ULIDs, UUIDs, or integer IDs, configure the type before running migrations:

Custom Morph Map

If your application uses morph aliases, enable custom mapping in the config:

Artisan Commands

Command Description
devespresso:life-cycle:create Interactively create a lifecycle with stages
devespresso:life-cycle:run Process and dispatch all pending lifecycle records
devespresso:life-cycle:logs-clean-up Delete logs older than log_retention_days
devespresso:life-cycle:completed-models-clean-up Delete completed records older than completed_model_retention_days

Database Schema

Table Description
system_life_cycles Lifecycle definitions
system_life_cycle_stages Ordered stages belonging to a lifecycle
system_life_cycle_models Per-model tracking of current position in a lifecycle
system_life_cycle_logs Immutable execution history (success and failure)

All tables use a bigIncrements internal primary key (internal_id) and a public ULID identifier (id) for foreign key relationships.

Testing

The package uses Orchestra Testbench with an SQLite in-memory database.

License

MIT


All versions of system-life-cycle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/database Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
illuminate/console Version ^10.0|^11.0
illuminate/queue Version ^10.0|^11.0
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 devespresso/system-life-cycle contains the following files

Loading the files please wait ...