PHPackages                             patinthehat/glacier - 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. [Framework](/categories/framework)
4. /
5. patinthehat/glacier

ActiveLibrary[Framework](/categories/framework)

patinthehat/glacier
===================

Lightweight console application framework for PHP

0.1.7(8y ago)014MITPHPPHP &gt;=7.1.0

Since Dec 8Pushed 8y ago1 watchersCompare

[ Source](https://github.com/patinthehat/glacier)[ Packagist](https://packagist.org/packages/patinthehat/glacier)[ RSS](/packages/patinthehat-glacier/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (2)Used By (0)

Glacier
-------

[](#glacier)

---

A lightweight framework for quickly putting together PHP CLI scripts and applications.

---

#### Install with composer

[](#install-with-composer)

`composer require patinthehat/glacier`

---

#### Events

[](#events)

Glacier allows you to write event-driven applications quite easily using `Events` and `EventListeners`.

Custom events extend the `Event` class, and names are generated automatically. Event names are generated by inserting a period before every capital letter (except the first) and making everything lowercase. For example, "MyEvent123" would trigger the "my.event123" event.

An event can be defined as simply as:

```
class MyEvent1 extends Event { }
```

Properties, etc. can be added as required.

To trigger an event, call `event()`:

```
event(new MyEvent1)
```

You may also send a payload along with the event by passing a second, optional parameter:

```
event(new MyEvent1, "my custom payload");
```

#### Event Listeners

[](#event-listeners)

Events are handled by event listeners, which are *automatically registered by the application*. No action needs to be taken other than defining an `EventListener` or `MultipleEventListener` class. To disable this behavior, set the property `$autoRegister` to false:

```
public static $autoRegister = false;
```

An event listener that handles events 'my.event1' and 'my.event2' can be defined as such:

```
class MyEventListener1 extends EventListener
{
    public static $events = [ 'my.event1', 'my.event2' ];

    public function handle($event, $payload = null)
    {
        app()->output()->write('[event fired] '.$event->name . PHP_EOL);
        return true;
    }
```

To listen for ALL events, the event name should be defined as '\*':

```
    public static $events = [ '*' ];
```

---

#### Commands

[](#commands)

Glacier allows support for multiple commands within the same application. To create a command, extend the `Command` class:

```
class MyCommand extends Command
{
    public static $autoRegister = true;
    public $name = 'mycmd';

    public function execute()
    {
	    $this->app->output()->writeln('my command!');
    }
}
```

By default, all commands *are automatically registered*. To disable this behavior, set the static property `$autoRegister` to false:

```
    public static $autoRegister = false;
```

If autoregistration is disabled, register it **before** calling `$app->run()`:

```
$app->registerCommand(new MyCommand);
```

---

#### Default Commands

[](#default-commands)

- TBD

---

#### Command-Line Arguments

[](#command-line-arguments)

Glacier will accept all command-line flags by default. To accept a flag with a value, you must call the `defineOption()` method on the `arguments()` method. Once done defining options, you must call `parse()`.

Once defined, even if the short flag is provided, its value can be accessed by calling `setting($name)`, such as `setting('test')`, even if `-t 55` was passed on the command line.

To define command-line options, use the following format:

```
defineOption(shortflag, long-flag, expects-value, default-value)
```

such as:

```
defineOption('t', 'test', true, 0)
```

In full, to define a command-line option:

```
$app->arguments()
    ->defineOption('t', 'test', true, 0)
    ->defineOption('a', 'all', false, false)
    ->defineOption('c', 'count', true, 10)
    ->parse();
```

This must be done before a call to `$app->run()`.

Any of these settings defined here could later be referenced, for example, as `setting('count')` or `setting('all')`.

If you simply wish to be able to handle flags with no values, you do not need to call `defineOption()`. To access, simply reference `app()->arguments()->hasOption('myflag')`:

```
  if (app()->arguments()->hasOption('quiet')) { ...
```

#### Configuration Files

[](#configuration-files)

- TBD

---

#### A Basic Application

[](#a-basic-application)

```
require(__DIR__.'/vendor/autoload.php');

use Glacier\Console\Application;
use Glacier\Console\DefaultCommand;
use Glacier\Events\Event;
use Glacier\Events\EventListener;
use Glacier\Events\MultipleEventListener;

class MyEvent1 extends Event { }
class MyEvent2 extends Event { }

//automatically registered with the application
class MyEventListener1 extends EventListener
{
    public static $events = [ 'my.event1', 'my.event2' ];

    public function handle($event, $payload = null)
    {
        app()->output()->write('[event fired] '.$event->name.'; listener: '.__CLASS__ . '; payload = '. (isset($payload->name) ? $payload->name : '') . PHP_EOL);
        return true;
    }
}

//automatically registered with the application
class MyEventListener3 extends MultipleEventListener
{
    public static $events = [ '*' ];
    protected $ignoreMissingHandlers = true;

    public function my_event1(Event $event, $payload = null)
    {
        echo '[1] hi from '.__CLASS__.': '.$event->name.PHP_EOL;
    }

    public function my_event2(Event $event, $payload = null)
    {
        echo '[2] hi from '.__CLASS__.': '.$event->name.PHP_EOL;
    }
}

class DemoCommand extends DefaultCommand
{
    public function initialize()
    {
       event(new MyEvent2);
    }

    public function execute()
    {
        event(new MyEvent1);
        app()->output()->writeln('hello from '.$this->getName());
    }

}

$app = new Application($argv,  __DIR__, true, false, [DemoCommand::class], false, false);

$app->arguments()
    ->defineOption('t', 'test', true, 0)
    ->parse();

$app->run();
```

Execution: `php myapp.php -t 55`**or**`php myapp.php --test=123`

---

### A Simple Glacier Application

[](#a-simple-glacier-application)

```
require(__DIR__.'/vendor/autoload.php');

use Glacier\Console\Application;
use Glacier\Console\DefaultCommand;

class DemoCommand extends DefaultCommand
{
    public $name = 'demo2';

    public function initialize()
    {
        //
    }

    public function execute()
    {
        if (app()->arguments()->hasOption('goodbye')) {
            app()->output()->writeln('goodbye from '.$this->getName());
        } else {
            app()->output()->writeln('hello from '.$this->getName());
        }
    }

}

$app = new Application($argv,  __DIR__, true, true, [DemoCommand::class], false, false);
$app->run();
```

Execution: `php myapp.php`**then**`php myapp.php --goodbye`

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

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 ~5 days

Total

2

Last Release

3072d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5508707?v=4)[Patrick Organ](/maintainers/patinthehat)[@patinthehat](https://github.com/patinthehat)

### Embed Badge

![Health badge](/badges/patinthehat-glacier/health.svg)

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

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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