Download the PHP package kamermans/haproxy-api without Composer

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

HAProxyAPI

PHP API for HAProxy administration

Build Status

This PHP API lets you programatically access HAProxy for both admin and read-only commands like enabling/disabling servers, and checking the status of servers. I can communicate via HAProxy over the builtin HTTP stats web page, using the built-in UNIX domain socket, or over TCP if, for example, you are proxying your domain socket to a TCP socket so you can access it remotely.

The HAProxy HTTP interface only supports Stats, EnableServer and DisableServer, so use of the domain or TCP socket is required for all other commands.

HAProxyAPI was written by Steve Kamerman and is distributed under the GNU GPLv3 license.


Getting Started

Before you can use HAProxyAPI, you'll need to include the class loader. The API is PSR-0 compliant and has builtin Composer support. If you don't know what that means, you probably just want to use the included class loader, autoload.php:

Then, you'll need to create an HAProxy\Executor which is used to run all the commands.

Connecting to HAProxy via HTTP

Make sure you have the stats interface enabled in your HAProxy config. You will also need admin privileges if you want to enable or disable servers. Currently, authentication is required to use this method.

Connecting to HAProxy via Socket

Socket communications requires the stats configuration option to be enabled, as well as the appropriate permission level to run the commands. Here's and example config for enabling the stats socket:

To use the UNIX domain socket interface for HAProxy, you pass its full filename to the constructor:

Connecting to HAProxy via TCP/IP

HAProxy does not ship with TCP/IP support, but it does support UNIX domain sockets. You can use something like socat or netcat/nc to make your domain socket accessible via TCP/IP. This example exposes the socket to the localhost on port 10010:

If you can access the socket via TCP/IP, you can use HAProxyAPI to connect to it as well (think socat + ssh-port-forwarding = secure-remote-admin).

For this setup, you use the same socket setup as above, but you pass a hostname and port instead:

Getting Statistics

To get a statistics object, use HAProxy\Stats::get($exec):

That will output something like this:

Using this information, you can get statistics about individual servers:

Output:

Enabling/Disabling Servers

You can put servers into maintanence mode (aka disabled mode) and bring them back up using the HAProxy\Command\DisableServer and HAProxy\Command\EnableServer HAProxyAPI commands.

Both commands take a backend service name (ex: foo-nodes) and a server name (ex: node01.foobar.com).

To execute commands, you pass them to the HAProxy\Executor::execute($command) method:


All versions of haproxy-api with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
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 kamermans/haproxy-api contains the following files

Loading the files please wait ....