Robert Eisele
Systems Engineer, Architect and DBA

PHP Defcon Extension

PHP Defcon is an Extension for PHP to define constants that are available during the whole server runtime - from server start to shutdown.

Overview

With this Extension you have the possebility to define global constants such as configuration constants that will be available during the whole server runtime.

Datatypes

PHP Datatypes

  • string
  • int
  • float
  • bool

Datatype Aliases

  • long - alias for int
  • real - alias for float
  • double - alias for float
  • logical - alias for bool
  • short - alias for int
  • boolean - alias for bool

Configuration

# Database Config
string DBHOST = "localhost";
string DBUSER = "root";
string DBPASS = "";
string DBNAME = "test";

# Parsertest
int T1 = 123;
int T2 = 1.3;
int T3 = "test";
real T4 = 1;

string T5 = hello # should work too

logical T6 = true;
logical T7 = false;
logical T8 = 234

Installation

Installing with `pecl` command-line utility

  1. Execute command "pecl install defcon"
  2. Make sure you have extension=defcon.so in your php.ini
  3. Add the configuration lines from above in your /etc/defcon.conf

Installing from sources

  1. Download defcon source package
  2. Unpack defcon source package
  3. Go to defcon folder and type "phpize && ./configure && make && make install"
  4. Make sure you have extension=defcon.so in your php.ini
  5. Add the configuration lines from above in your /etc/defcon.conf

Compiling Defcon into PHP

  1. Download defcon source package
  2. Unpack defcon source package to $PHP_SOURCE_DIR/ext/defcon
  3. In php source root directory run commands: "rm configure && ./buildconf --force"
  4. Configure PHP with command "./configure --with-defcon"
  5. Run make && make install
  6. Add the configuration lines from above in your /etc/defcon.conf

Links