PHPackages                             afonzeca/arun - 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. afonzeca/arun

ActiveProject[Framework](/categories/framework)

afonzeca/arun
=============

Arun CLI Microframework for Php 7.2+

v0.45.1-alpha(7y ago)048Apache-2.0PHPPHP &gt;=7.2.0

Since Oct 25Pushed 7y ago1 watchersCompare

[ Source](https://github.com/afonzeca/arun)[ Packagist](https://packagist.org/packages/afonzeca/arun)[ Docs](https://github.com/afonzeca/arun)[ RSS](/packages/afonzeca-arun/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (10)Dependencies (10)Versions (12)Used By (0)

"Arun" (CLI Microframework) for PHP7.2+ - Version 0.45-alpha - (C) 2018 by Angelo Fonzeca
-----------------------------------------------------------------------------------------

[](#arun-cli-microframework-for-php72---version-045-alpha---c-2018-by-angelo-fonzeca)

[![](docs/images/arunlogo.jpg)](docs/images/arunlogo.jpg)

### Summary

[](#summary)

- [What is Arun?](#what-is-arun)
- [It is magic!](#it-is-magic)
- [Why was Arun born?](#why-was-arun-born)
- [Create an Arun project](#create-an-arun-project)
- [Coding Tutorials](#coding-tutorials)
- [Code Auto Generation](#code-auto-generation)
- [Configuration File Support](#configuration-file-support)
- [Phar self-contained executable generation](#phar-self-contained-executable-generation)
- [Facades support](#facades-support)
- [What about the internal Arun Engine?](#what-about-the-internal-arun-engine)
- [What's next?](#whats-next)
- [License Info](#license-info)
- [Thanks to...](#thanks-to)
- [About releases](#about-releases)
- [Contacts](#contacts)

### What is Arun?

[](#what-is-arun)

Arun is a microframework for easily developing "console applications" written in PHP OOP. It is quite different from other similar frameworks/libraries (Like Symfony Console component, Silly, etc.) because Arun uses "Convention Over Configuration" and Annotations for managing commands and associated code (your console application).

The Arun Microframework has an "out-of-the-box" native support for Dependency Injection by using *Containers* and *Autowire*(thanks to PHP-DI), facades and an organized tree for easily writing your code in a simple way.

Starting from the 0.43-alpha version, Arun can auto-generate code for fast and easy development (See Chapter 'Code Auto-Generation' for further information).

After your project is finished, you can also create a self-contained executable (.phar) thanks to gen:phar embedded action.

If you want to analyze the source code note that ARUN has been divided in two parts: this project (the Arun "boilerplate") and the "core" which containts the most important part of the project (\[\])

*DISCLAIMER: This product is a prototype at an early stage of development and could have security issues... DO NOT USE IT IN PRODUCTION ENVIRONMENTS*

### It is magic!

[](#it-is-magic)

You create a class in a specific directory (e.g. "app/Console/Domains/CommandNameDomain.php") which extends a specific "DomainCommand" class, then you define your methods with your code inside, type hinting every parameter (recommended), set a default value for optional parameters... and you have a new command that you can call from CLI as follow:

```
./arun YOURCLASSNAME:YOURMETHOD param1 param2 [param3] [param4=withdefaultvalue]
```

(see the Examples paragraph for better understanding how it works...)

You can also use options (-i --u=username --password=something --check ).

*NOTE: YOURCLASSNAME is called "DOMAIN" and YOURMETHOD is called "ACTION" in the Arun universe...*

Arun will do all the job for you... When invoked, it instantiate an object which corresponds to "DOMAIN", and calls the Method of the class that corresponds to "ACTION".

Every parameter from CLI is directly mapped to each parameter of the DOMAIN/ACTION method itself thanks to the PHP reflection. The parameters are also "casted" according to the specified type during the method declaration.

Another "magic" inside Arun is that you have a Dependency Container support (Php-Di) so you can easily inject Services inside your classes.

The last but not the least, Arun can generate an help file "Automatically" for each DOMAIN and its ACTIONS. You can also add additional information (help text) thanks to "annotations" (special comments inside classes).

By using annotations it is also possible to define options and their help description.

Arun also supports "out-of-the-box" the phar generation, so your package will be "self-contained" and can be installed as exacutable in your /bin, /opt, etc. thanks to Box2 support (See )

[![](docs/video/demo.gif)](docs/video/demo.gif)

### Why was Arun born?

[](#why-was-arun-born)

Arun was born as a tool for creating a full working framework called "Sensuikan" on which I'm working on. Anyway during the development I realized that Arun could be used as a stand-alone component. So I made the "Arun Microframework Package".

It can be useful when:

1. You want to write command line code with minimal dependencies in pure PHP OOP style (but you want autoloading composer support, dependency injection, well organized project... Out of the box!)
2. You need to re-organize/aggregate your cli legacy code inside a more robust project without spending your time for managing command line, parameters, value mapping, etc.
3. As a base for writing your own framework... Arun can be a good candidate for realizing tools like "Composer", "Laravel Artisan", etc.
4. You want to write workers or services in PHP that can be called from your cron, command line scripts, etc.

Anyway... Too much words... Now Let's making some code... ;-)

### Create an Arun project

[](#create-an-arun-project)

You need php 7.2 and Composer installed () on your machine (tested only on Linux/Ubuntu/Mint).

```
composer --stability=alpha create-project afonzeca/arun MyFirstArunApplication
```

NOTE:

- Due to project "alpha" stage, you MUST specify the version of the framework, as showed above.
- The ArunCore has been separated from Arun starting from the 0.41 - alpha version. The "core" will be installed by composer automatically (You'll find it under vendor/afonzeca/arun-core). Please check [Arun-Core on Github](https://github.com/afonzeca/arun-core) for further details and API library documentation.

*DISCLAIMER: This product is at an early stage of development and could have stability and security issues... DO NOT USE IT IN PRODUCTION ENVIRONMENTS*

### Coding Tutorials

[](#coding-tutorials)

Arun can auto-generate code itself, but in the next few examples I prefer to have a "craftmanship" approach so I will describe step-by-step how to manually develop using the platform.

If you want skip examples and read about auto-generation code directly (not recommended), please refer to chapter ['Code Auto-Generation'](#code-auto-generation) for further information.

Before starting let's create the first project with:

```
composer --stability=alpha create-project afonzeca/arun MyFirstArunApplication

cd MyFirstArunApplication
```

**Tutorial 1 - How to write basic command line application**

You want to implement the following domain and action (for our purposes it will be a fake function that will write only messages on screen...):

```
./arun table:create users
```

Note: If you like, you can rename "arun" executable to a different name... but if you like Arun Project, I'll be pleased you left the name unchanged ;-)

Anyway, for starting the development you need to do the following actions:

*Step 1*

Inside the folder app/Console/Domains you need to add a class called "TableDomain.php", with its namespace "App\\Console\\Domains".

The class will extends the "DomainCommand base class" like this:

```
