PHPackages                             antonskudilo/cliver-core - 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. antonskudilo/cliver-core

ActiveLibrary[Framework](/categories/framework)

antonskudilo/cliver-core
========================

Cliver core

v0.1.6(7mo ago)011MITPHPPHP &gt;=8.3

Since Aug 29Pushed 7mo agoCompare

[ Source](https://github.com/antonskudilo/cliver-core)[ Packagist](https://packagist.org/packages/antonskudilo/cliver-core)[ Docs](https://github.com/antonskudilo/cliver-core)[ RSS](/packages/antonskudilo-cliver-core/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (8)Used By (0)

PHP CLIVER (Core)
=================

[](#php-cliver-core)

A minimalistic **core** for building a PHP CLI framework.
The goal of this project is to provide a foundation (dependency injection container, services, providers, command registry) on top of which you can build your own CLI applications and extend functionality.

Core features
-------------

[](#core-features)

- Simple command registration
- Dependency Injection support
- Service providers and singletons
- Can be used as a library to build your own CLI framework

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

[](#requirements)

- PHP 8.3 or higher

Version
-------

[](#version)

Current release: **0.1.0**

You can require the framework core via Composer:

```
composer require antonskudilo/cliver-core:^0.1
```

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

[](#installation)

```
git clone https://github.com/antonskudilo/cliver-core.git
cd cliver-core
composer install
composer dump-autoload
```

Quick start
-----------

[](#quick-start)

```
php bin/cliver
```

*By default, when no command name is provided, the application runs the `HelpCommand`. It displays all available commands in the format signature → description:*

```
Available commands:
help   Show the list of available commands
```

*The default command can be redefined in the `Providers/AppServiceProvider` (see item "Service configuration").*

Running commands
----------------

[](#running-commands)

To register and use commands, they must be added to `Providers/CommandServiceProvider`.
Core commands (for example, `HelpCommand`) should be registered in `Console/Commands/CoreCommands.php`.

#### Register the command in `Console/Commands/CoreCommands.php`:

[](#register-the-command-in-consolecommandscorecommandsphp)

```
    public static function commands(): array
    {
        return [
            HelpCommand::class,
        ];
    }
```

Each command defines its own static method `getName`, which is used as the CLI signature.

#### Help command:

[](#help-command)

```
final readonly class HelpCommand implements CommandInterface
{
    public static function getName(): string
    {
        return 'help';
    }

    ...
}
```

Dependency injection container
------------------------------

[](#dependency-injection-container)

The framework core includes a simple DI container. Core services should be registered in `Providers/CoreProviders`. Services can be registered in `Providers/AppServiceProvider` or provided dynamically.

Service configuration
---------------------

[](#service-configuration)

#### Service bindings could be defined in the `Providers/AppServiceProvider`.

[](#service-bindings-could-be-defined-in-the-providersappserviceprovider)

It contains the `register` method, which can be used for `bind` and `singleton`, using the container instance passed as a parameter.

This allows you to configure how dependencies are resolved across the application, and makes it easy to swap or mock implementations in tests.

#### `Providers/AppServiceProvider`:

[](#providersappserviceprovider)

```
final class AppServiceProvider implements ServiceProviderInterface
{
    public function register(Container $container): void
    {
        $container->bind(
          AppConfig::KEY_DEFAULT_COMMAND,
          HelpCommand::class
        );
    }
}
```

#### Now you can run:

[](#now-you-can-run)

```
php bin/cliver help
```

Base test case
--------------

[](#base-test-case)

A base test class `Testing/TestCase.php` is provided to bootstrap the application and container for every test:

```
abstract class TestCase extends BaseTestCase
{
    protected Container $container;

    protected function getContainer(string $basePath): void
    {
        $this->container = Bootstrap::init($basePath);
    }

    protected function makeApp(): Application
    {
        return $this->container->get(Application::class);
    }

    protected function fake(string $abstract, object $fake): object
    {
        $this->swap($abstract, $fake);

        return $fake;
    }

    protected function swap(string $abstract, object $fake): void
    {
        $this->container->bind($abstract, $fake);
    }

    protected function fakeSingleton(string $abstract, object $fake): object
    {
        $this->swapSingleton($abstract, $fake);

        return $fake;
    }

    protected function swapSingleton(string $abstract, object $fake): void
    {
        $this->container->singleton($abstract, $fake);
    }
}
```

Helpers
-------

[](#helpers)

This project includes a set of helper functions grouped into console, environment, and path utilities. They simplify working with CLI output, environment variables, and project paths.

#### Console helpers

[](#console-helpers)

- `errorln(string $message = '')` – print a message to STDERR with a \[Error\] prefix.
- `pad(string $label, string $value, int $padLength = 25)` – format label/value pairs with aligned output.
- `padAuto(array $rows)` – automatically align and print an array of key =&gt; value pairs.
- `println(string $message = '')` – print a message to STDOUT with a newline.

#### Environment helpers

[](#environment-helpers)

- `env(string $key, mixed $default = null)` – retrieve an environment variable with type casting (true/false/null).
- `is_debug()` – check if APP\_DEBUG is enabled.
- `loadEnv(string $path)` – load variables from a .env file into $\_ENV, $\_SERVER, and getenv().

#### Path helpers

[](#path-helpers)

- `load_from(string $path, mixed $default = [])` – loading data from a specific file
- `join_path(string $base, string $path = '')` – safely concatenate directory paths.

Environment configuration
-------------------------

[](#environment-configuration)

The application uses a `.env` file in the project root to configure environment variables. A template file `.env.example` is provided and can be copied to create your own `.env`.

#### Currently, it supports:

[](#currently-it-supports)

- `APP_DEBUG` — when set to true, full stack traces are displayed in the console. Otherwise, only a short error message is shown. This allows easy switching between development and production modes.

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

[](#project-structure)

```
├── src/                          # Core source code
│   ├── Console/                  # CLI commands, input/output handling
│   │   └── Commands/             # Core commands, CommandInterface
│   ├── Core/                     # Bootstrap, DI container
│   ├── Exceptions/               # Exceptions
│   ├── Helpers/                  # Helpers should be included in src/helpers.php
│   ├── Providers/                # Core service providers
│   └── Testing/                  # Testing utilities
├── tests/                        # PHPUnit tests
├── cliver                        # CLI entry script
├── composer.json
└── phpunit.xml
```

### License

[](#license)

MIT

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance62

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 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

Every ~3 days

Total

7

Last Release

238d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/49bcb9b91545bede484ad6ab90a9c12c521c21e8d0beb9520cd6fe37d9ba5e20?d=identicon)[antonskudilo](/maintainers/antonskudilo)

---

Top Contributors

[![antonskudilo](https://avatars.githubusercontent.com/u/54507545?v=4)](https://github.com/antonskudilo "antonskudilo (10 commits)")

---

Tags

phpcliconsoleframeworkcommandscliver

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/antonskudilo-cliver-core/health.svg)

```
[![Health](https://phpackages.com/badges/antonskudilo-cliver-core/health.svg)](https://phpackages.com/packages/antonskudilo-cliver-core)
```

###  Alternatives

[utopia-php/cli

A simple CLI library to manage command line applications

41396.4k10](/packages/utopia-php-cli)

PHPackages © 2026

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