Where code meets community
ALPHA

When using the configuration file based approach of including FirePHP many configuration options are available. These options make it possible to seamlessly integrate FirePHP into toolchains and deployment procedures without needing to add environment detection code to the application.

Since FirePHP is designed to wrap the application with minimal interference (see Concepts) the configuration options presented below are essential in ensuring that the application does not need to be modified when deploying to different environments.

Package Configuration

An application is a package and a package is configured via a package.json file which is called the package descriptor.

The package descriptor follows the CommonJS Packages specification and the relevant keys are:

{
  // REQUIRED - Same URL for all deployments of same package
  "uid": "<Unique URL>",
  // OPTIONAL - First sentence (until first .) becomes a title
  "description": "<Package short description>",
  // OPTIONAL
  "homepage": "<Homepage URL>",
  // OPTIONAL
  "bugs": "<Bug tracker URL or email address>",
  "implements": {
    "cadorn.org/insight/@meta/package/0": { ... }
    },
    "cadorn.org/insight/@meta/config/0": { ... }
  }
}

The implements key holds configurations for specific components identified by URI.

implements URIs map to json-schema documents that can be used to validate configurations.

implements: cadorn.org/insight/@meta/package/0

{
  "implements": {
    "cadorn.org/insight/@meta/package/0": {
      // OPTIONAL
      "links": {
        // Shortcuts to important information
        "quick": {
          "<Label>": "<URL>",
          "<Label>": {
            "target": "<Target>",  // 'tab' (default), 'window' or 'hidden'
            "url": "<URL>"
          }
        }
      }
    }
  }
}

implements: cadorn.org/insight/@meta/config/0

{
  "implements": {
    "cadorn.org/insight/@meta/config/0": {
      // OPTIONAL - Defaults to ./credentials.json
      "credentialsPath": "/.../credentials.json",
      "cache": {
        // OPTIONAL - Defaults to sys_get_temp_dir()
        "path": "<CachePath>",
      },
      "server": {
        // OPTIONAL - Defaults to "/"
        "path": "/<ServerScript.php>",
        // OPTIONAL - Defaults to same as browser request
        "host": "<Hostname>",
        // OPTIONAL - Defaults to same as browser request
        "port": "<Port>",
        // OPTIONAL - Defaults to same as browser request
        "secure": <[true|false]>
      },
      // OPTIONAL - Accessible paths (absolute or relative)
      "paths": {
        "./": "allow",
        "./credentials.json": "deny"
      },
      // OPTIONAL - Encoder options
      "encoder": {
        "depthNoLimit": false,
        "lengthNoLimit": false,
        "maxDepth": 5,
        "maxStringLength": 5000,
        "maxArrayDepth": 3,
        "maxArrayLength": 25,
        "maxObjectDepth": 3,
        "maxObjectLength": 25,
        "exception.traceMaxLength": -1,  // no maximum
        "trace.maxLength": -1  // no maximum
      }
    }
  }
}

Any relative paths are relative to the package.json file and may point outside of the package root.

  • credentialsPath - Optionally set an alternate path to a credentials.json file. If set the credentials.json file next to package.json is ignored while the credentials.local.json file will still be loaded.

  • cache.path - Optionally set an alternate cache path. By default the value returned by sys_get_temp_dir() is used. The path may be relative to the config file or an absolute path.

    If sys_get_temp_dir() is not available dirname(constant('INSIGHT_CONFIG_PATH')) is used and if INSIGHT_CONFIG_PATH is not set dirname($_SERVER['SCRIPT_FILENAME']) is used. In the latter cases .cache is appended.

  • server.path - Must be set to a PHP script relative to the document root and the <ServerScript.php> file must simply include FirePHP with the same configuration file set as for the application and may indeed be pointed to any application PHP script that includes FirePHP. In these cases FirePHP will intercept all client requests and respond accordingly preventing the application script from ever running where appropriate.

    The path is typically an absolute path including a forward slash. If a relative path is provided (./...) the <ServerScript.php> is expected to be found relative to the same directory the original request pointed to.

  • server.secure - If set to true a secure HTTPS request will be made to the <ServerScript.php> instead of using the same protocol as the browser request.

  • paths - Holds access rules for which paths are accessible to the FirePHP client. This is used to load source files for display on the client for example.

  • encoder - Holds options for the variable encoder. See Insight API.

Environment specific Configuration

It is useful to adjust the configuration for a specific deployment environment to allow additional paths or set a central credentials file for example.

Place a file called package.local.json next to package.json. All configuration directives will be merged on top of the defaults provided by package.json. It is intended that package.local.json be ignored by all version control systems.

If you have a central credentials.json file to be used for all applications in an environment you can set the following in the package.local.json file:

{
  "implements": {
    "cadorn.org/insight/@meta/config/0": {
      "credentialsPath": "/.../credentials.json"
    }
  }
}

If this custom path is set any credentials.json file residing next to package.json will be ignored while the credentials.local.json file will still be loaded.

To add more application-specific credentials use a credentials.local.json file next to package.json.

Server-wide Inclusion

To include FirePHP for all virtual hosts on a webserver set the auto_prepend_file php.ini directive:

// Apache
php_value auto_prepend_file phar://.../firephp.phar/FirePHP/Init.php

FirePHP will only be enabled if a configuration file is also set before PHP executes (see Virtual Host based Configuration).

FirePHP will only be loaded if x-wf- or x-insight request headers are found. This means there will be negligible performance degradation if FirePHP is not needed as is the case for most visitors to your application.

Virtual Host based Configuration

Instead of setting the configuration file in PHP:

define('INSIGHT_CONFIG_PATH', '/.../package.json');

Set it in the virtual host configuration of the webserver:

// Apache
SetEnv INSIGHT_CONFIG_PATH /.../package.json

To force the use of a specific credentials file use:

// Apache
SetEnv INSIGHT_CONFIG_PATH /.../package.json,/.../credentials.json

Homepage: Sourcemint.com

Status

Sourcemint is incomplete ALPHA technology and continuously evolving in sync with underlying and related projects. Production ready aspects will be documented and made available in time. Your Feedback is welcome and appreciated!

Who

Sourcemint is one of the results of intense focus by Christoph Dorn over the past several years and continuous exploration throughout Christoph's interest in software development over the past 15+ years.

Sourcemint is the love child of one person guided by the voices of passionate developers at the top of their game who are leading the industry into a new era of software development.

What

Sourcemint is an integral part of Christoph's work intended to realize his dream of one global toolchain under which components may be arbitrarily combined into maintainable mission critical systems by providing an all-encompassing and organized package repository from which consistent and autonomic systems may be built.

Sourcemint provides an automated software building and integration service as well as an intelligent software delivery network to distribute built software to all deployed systems and Internet users.

This means an arbitrary (code, configuration, network, ...) change may be made to a software system which can then be automatically built, tested, distributed and deployed. Every change constitutes a completely new system made possible by the fact that changes, any changes, are cheap and fully tested in every way before going live.

Just imagine what this means in your daily work.

Why

Automated software builds, continuous integration processes, streamlined issue trackers, community supported software, source control, online collaboration and automated cloud deployment have wet our appetite but hardly scratch the surface of what it actually means to have a completely automated production cycle from idea to delivery. The full potential is only realized once these separate solutions addressing different areas work together harmoniously.

What has been missing is new ways of looking at how to build software.

How

Christoph's work provides a new way to build software that is not necessarily new in the sense of ideas or technology but rather arrangement and timing. Christoph has through exploration and experimentation distilled current cutting edge technology, knowledge and wisdom into a toolchain platform called PINF available open source under the MIT license to realize a new breed of software.

Imagine software and systems that just work and are a pleasure to maintain.

Sourcemint is built entirely on PINF, as is all of Christoph's work, and can be used by any developer to tap into the power of the PINF approach to build open source or commercial libraries, frameworks, applications, systems and services.

Christoph's hope is that PINF and related projects will provide a foundation for developers to cooperate more widely and experiment with new ideas by eliminating some of the major constraints imposed by traditional toolchains. Traditional toolchains create systems that typically rot because they are practically impossible to refactor. We need a toolchain such as PINF which has refactorability designed into its core.

Let's create software that breathes with life and is in large part self-sustaining!

You

Join Christoph in his mission to help you, the developer, and help yourself by broadly applying the tools and approaches you know work to all of your work. Lean on PINF, your mind is begging you. Learn it, teach others, and let your inspiration soar!

Follow Sourcemint and PINF on twitter to watch for news of cutting-edge tools, tutorials and services coming online. You can also follow Christoph's work directly.