PHPackages                             axazara/bankai - 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. [DevOps &amp; Deployment](/categories/devops)
4. /
5. axazara/bankai

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

axazara/bankai
==============

A Laravel Envoy deployment package for streamlined and consistent deployment processes across projects.

v1.0.1(3w ago)64.7k↑607.1%[2 PRs](https://github.com/axazara/bankai/pulls)MITPHPPHP ^8.1CI passing

Since Jun 3Pushed 1w agoCompare

[ Source](https://github.com/axazara/bankai)[ Packagist](https://packagist.org/packages/axazara/bankai)[ Docs](https://axazara.com)[ RSS](/packages/axazara-bankai/feed)WikiDiscussions main Synced yesterday

READMEChangelog (2)Dependencies (11)Versions (11)Used By (0)

Bankai
======

[](#bankai)

Bankai offers a streamlined solution for achieving zero-downtime deployments in Laravel applications using [Envoy](https://laravel.com/docs/envoy). This guide covers installation, configuration, and deployment, complete with examples and detailed explanations.

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

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.x, 11.x, 12.x or 13.x

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

[](#installation)

Begin by integrating Bankai with your Laravel project via Composer:

```
composer require axazara/bankai --dev
```

Configuration
-------------

[](#configuration)

After installation, initialize Bankai with the following command:

```
php artisan bankai:install
```

This will:

- Publish `config/bankai.php` in your config directory.
- Add `Envoy.blade.php` to your project's root.

Customize `config/bankai.php` according to your project's needs.

### Example configuration (`config/bankai.php`)

[](#example-configuration-configbankaiphp)

```
return [
    // General deployment settings
    'settings' => [
        // Git repository to deploy (HTTPS or SSH URL)
        'repository_url'    => 'git@github.com:your-org/your-repository.git',
        // Slack Incoming Webhook URL; leave null to disable notifications
        'slack_webhook_url' => null,
    ],

    // Define your environments, e.g. staging and production
    'environments' => [
        'staging' => [
            'ssh_host'         => 'your-host',       // SSH host of the server
            'ssh_user'         => 'your-user',       // SSH user used for deployment
            'url'              => 'https://staging.your-app.com', // Application URL
            'branch'           => 'main',            // Branch to deploy
            'path'             => '/var/www/your-app', // Deployment directory on the server
            'php'              => 'php',              // PHP binary
            'composer'         => 'composer',         // Composer binary
            'composer_options' => '',                 // Extra options passed to `composer install`
            'migration'        => false,              // Run migrations
            'seeder'           => false,              // Run seeders
            'maintenance'      => false,              // Toggle maintenance mode during deploy
            'octane'           => [
                'install' => false,                   // Install Laravel Octane
                'reload'  => false,                   // Reload Octane after deploy
                'server'  => 'swoole',                // roadrunner, swoole, frankenphp or openswoole
            ],
            'horizon' => [
                'terminate' => true,                  // Terminate Horizon after deploy
            ],
            'queue' => [
                'restart' => false,                   // Restart queue workers after deploy
            ],
        ],
    ],
];
```

### Example `Envoy.blade.php`

[](#example-envoybladephp)

`bankai:install` generates this file for you. The Laravel bootstrap is handled by `AxaZara\Bankai\Bankai::bootstrap()`, so your Envoy script stays to the point:

```
@include('vendor/autoload.php')

@setup
    try {
        extract(AxaZara\Bankai\Bankai::bootstrap($env));
    } catch (Throwable $e) {
        echo $e->getMessage();
        exit(1);
    }
@endsetup

@import('vendor/axazara/bankai/src/Envoy.blade.php')

@task("run:before_deploy")
    # Runs before the deployment starts (the new release is not cloned yet).
    true
@endtask

@task("run:after_deploy")
    cd "{{ $releasePath }}"
    # Your post-build commands here, e.g. php artisan jwt:secret --force
@endtask

@task("run:after_rollback")
    cd "{{ $currentReleasePath }}"
@endtask
```

Deployment
----------

[](#deployment)

The first deployment follows five steps. Once set up, day-to-day deployments are just Step 4.

### Step 1 — Prepare the deployment directories

[](#step-1--prepare-the-deployment-directories)

Set up your deployment environment:

```
vendor/bin/envoy run setup --env={your-environment}
```

This creates the directory structure on the server:

- **releases/**: Houses every deployment.
- **shared/**: Resources shared across releases, such as the `.env` file and `auth.json`.
- **backups/**: Reserved for release backups.
- **current**: Symlink pointing to the live release.

Your application key is generated and stored in `shared/.env`.

> This is a one-time setup, generally run from your local machine.

### Step 2 — Configure your environment file

[](#step-2--configure-your-environment-file)

Edit the shared environment file created during setup. Every release symlinks to it:

```
{path}/shared/.env
```

### Step 3 — Configure Composer authentication

[](#step-3--configure-composer-authentication)

Required only if your application pulls **private** Composer packages or registries. Add an `auth.json` file to the shared directory:

```
{path}/shared/auth.json
```

Bankai symlinks `shared/auth.json` into each release before running `composer install` (during both `setup` and `deploy`), so Composer can authenticate. Because it lives in `shared/`, it is created once and reused by every release.

If your **first** `setup` already needs private packages, create the directory and the file beforehand so they exist when setup runs `composer install`:

```
mkdir -p {path}/shared && editor {path}/shared/auth.json
```

See the [Composer authentication documentation](https://getcomposer.org/doc/articles/authentication-for-private-packages.md) for the expected file format.

### Step 4 — Deploy

[](#step-4--deploy)

```
vendor/bin/envoy run deploy --env={your-environment}
```

> This can be run from your local machine or from your CI/CD pipeline. At [Axa Zara](https://axazara.com), we deploy automatically after each merge to the `staging` or `release` branch.

### Step 5 — Configure your web server

[](#step-5--configure-your-web-server)

Point your web server at the `current/public` directory. For example, with [Laravel Forge](https://forge.laravel.com/) you should set your site's web directory to `current/public`. The `current` symlink always points to the latest release.

Lifecycle hooks
---------------

[](#lifecycle-hooks)

Bankai exposes three hooks you can define in your `Envoy.blade.php`:

- `run:before_deploy` runs before the new release is cloned.
- `run:after_deploy` runs after the release is built, before it goes live.
- `run:after_rollback` runs after a rollback completes.

Example:

```
@task("run:after_deploy")
    cd {{ $releasePath }}
    php artisan jwt:secret --force
@endtask
```

The following variables are available in your tasks:

- `$releasePath` — path to the release being deployed.
- `$currentReleasePath` — path to the `current` symlink (the live release).
- `$sharedPath` — path to the shared directory.
- `$releasesPath` — path to the releases directory.
- `$php` — path to the PHP binary.
- `$composer` — path to the Composer binary.

Rollback
--------

[](#rollback)

Quickly revert to the previous release:

```
vendor/bin/envoy run deploy:rollback --env={your-environment}
```

Additional commands
-------------------

[](#additional-commands)

- List releases: `vendor/bin/envoy run releases --env={your-environment}`
- List backups: `vendor/bin/envoy run backups --env={your-environment}`

Zero-downtime deployment mechanics
----------------------------------

[](#zero-downtime-deployment-mechanics)

1. **New release preparation**: Bankai creates a new release in the `releases/` directory.
2. **Symlink switching**: The `current` symlink is switched atomically to the new release.
3. **Shared resources**: Consistency across deployments is maintained via the shared directory and files.
4. **Rollbacks**: Revert to a previous release at any time.
5. **Cleanup**: Old releases are pruned, keeping the three most recent.

Sentry integration
------------------

[](#sentry-integration)

Bankai can record a release in Sentry after each deployment. To enable it, add a `sentry` block to `config/bankai.php`:

```
'sentry' => [
    'enabled'      => false,
    'organization' => 'your-organization',
    'project'      => 'your-project',
    'token'        => 'your-token',
    'version'      => null, // Defaults to the current release name when null
],
```

- `sentry.enabled`: Set to `true` to enable Sentry integration.
- `sentry.organization`: Your Sentry organization.
- `sentry.project`: Your Sentry project.
- `sentry.token`: Your Sentry auth token. Learn more [here](https://docs.sentry.io/product/accounts/auth-tokens).
- `sentry.version`: The Sentry release version. Defaults to the current release name.

Contributing
------------

[](#contributing)

Contributions are welcome.

Security vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover a security vulnerability within this package, please email Axa Zara Security at . All security vulnerabilities will be promptly addressed.

License
-------

[](#license)

This project is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance96

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.8% 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 ~4 days

Total

2

Last Release

25d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d886ac75fa41d8fc4d03c7ae520386c695c74d608ba4ae25fed3ad1ffcef7e6?d=identicon)[axazara](/maintainers/axazara)

---

Top Contributors

[![EliasElimah](https://avatars.githubusercontent.com/u/65785746?v=4)](https://github.com/EliasElimah "EliasElimah (28 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

### Embed Badge

![Health badge](/badges/axazara-bankai/health.svg)

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

###  Alternatives

[in2code/in2publish_core

Content publishing extension to connect stage and production server

40143.4k](/packages/in2code-in2publish-core)[tiamo/phpas2

PHPAS2 is a php-based implementation of the EDIINT AS2 standard

4778.9k](/packages/tiamo-phpas2)[wapmorgan/php-rpm-packager

RPM packager for PHP applications.

106.6k](/packages/wapmorgan-php-rpm-packager)

PHPackages © 2026

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