Download the PHP package epiecs/mikodo without Composer

On this page you can find all versions of the php package epiecs/mikodo. 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 mikodo

Mikodo

Concurrent library on top of phpmiko. Speeds up the process of sending commands. There are included libraries for inventory management Libraries. Supported libraries include and are not limited to: Nornir yaml files, PhpIpam,...

Requires:

Installation:

Supported inventories:

Implemented
Planned

Basic examples:

Initializing Mikodo

Buffer size

The size in bytes that is available for each worker for communicating to the parent process. Set this to a higher number if you require a lot of text to be sent (eg.) complete config files. You can set this lower to reduce memory usage but you might not receive all output.

Running commands

Mikodo uses the same 3 methods like Phpmiko to send commands to devices: cli, operation and configure.

When sending commands you can either provide the method with a string or an array consisting of commands. Either way is fine. When providing an array the commands are run in order.

For the difference between the types of commands you can refer to the Phpmiko documentation

Preparing the inventory

Mikodo makes use of an inventory to perform its magic. The most basic way is to provide the inventory() method with an array consisting of hosts:

Each host should at least include the most basic required information for Phpmiko: __device_type, username, password and hostname__.

Sending command(s)

When the inventory has been prepared you can start sending commands.

If all went well you will see output like this. Offcourse in real life you will have (pretty?) colors.

Retrieving results

Mikodo will return the values in the form of an array where you can expect a key for each host and within the key of that host another key per command that has been run.

Printing results

To output the results to the terminal you just provide the returned results to the Mikodo->print() function.

Also, in real life you should get pretty colors.

Inventories

To ease your life Mikodo includes several inventory providers.

Inventories allow you to easily select specific hosts and/or groups from your inventory. Inventories also allow you to set default values on a global and/or group level.

You can even mix and match different inventories. One example can be that you load all hosts from PhpIpam and supply a default username/password via a simpleinventory.

One caveat that you have to take into account is the order in which the settings are applied.

The order of preference is hosts > groups > defaults. Imagine a situation where you have an inventory and have set a default username and password in the default settings. Within your inventory you also have one host where there is a password set within the host config.

The password defined in the host will take precedence over the password provided in the default settings.

Writing your own inventory providers

All inventory providers can extend the base inventory class and should implement the DeviceInterface interface.

It is recommended to extend the baseInventory class and use the sethosts/setgroups/setdefaults commands. These commands will make sure that the config is merged correctly as expected.

The InventoryInterface provides you with a nice structure as how a array containing hosts, groups and defaults should function.

Base inventory

The Base inventory can be initialized in three ways

example

The following methods are supported:

getGroups method

When using the getGroups method there is an optional parameter called $filterGroups.

Gets all hosts from the inventory based on the groupnames that are supplied in the $groups parameter.

When an array with filterGroups is provided the inventory will return a bisection of only those groups that are in both the $groups and $filterGroups array

The $groups array fills the resultset with all provided groups and $filterGroups helps reduce it

eg. if you request all devices within the group cisco and switches and wish to use only the devices that are also member of the nexus and europe groups

PhpIpam inventory

Mikodo can use an existing instance of PhpIpam. The inventory provider will fetch all devices from phpipam and will automatically apply some groups to each hostname as long as the corresponding value in phpipam exists and isn't null.

Afterwards if deemed neccesary you can still set group and/or default settings via the provided inventory methods.

A group will be applied for:

If a custom field is supplied for username, password, port and/or device_type then this will not be applied as a group but directly to the host object. This way it is possible to set some defaults in PhpIpam

If you wish you can also provide a custom field named 'groups' containing comma delimited groups. These will be added to the groups known for that device.

The following authentication methods are supported:

Nornir inventory

If you like Nornir you most likely already have a Nornir inventory. I have the following directory structure in my project folder:

You can load this directory with the NornirInventory provider and query it just the same way like a can with the base inventory. The only file that is required is the hosts.yaml file.

For the sake of simplicity I will use the following inventory as reference. Although brief it does suffice as an example to show you priorities of all inventory components.

default.yaml

groups.yaml

hosts.yaml


All versions of mikodo with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
ext-sockets Version *
ext-pcntl Version *
epiecs/phpmiko Version ^1.0
symfony/yaml Version ^4.3
league/climate Version ^3.5
guzzlehttp/guzzle Version ^6.3
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 epiecs/mikodo contains the following files

Loading the files please wait ....