Overview

Lets you execute a Solar-based script in a separate PHP process, then get back its exit code, last line, and output.

Intended use is for documentation and testing, where you don't want the classes loaded in the main environment to interact with the classes in the current environment.

An example to run echo "hello world!" in a separate process:

<?php
require_once 'Solar.php';
Solar::start();

$ini = array(
    'include_path'    =>  '/path/to/lib',
    'error_reporting' =>  E_ALL | E_STRICT,
    'error_display'   =>  1,
    'html_errors'     =>  0,
);

$php = Solar::factory('Solar_Php');

$php->setIniFile(false)
    ->setIniArray($ini)
    ->runSolarCode('echo "hello world!\n"');

Solar::stop();

Package

This class is part of the Solar package.

Inheritance:

Configuration Keys

  • php: Command to invoke the PHP binary.

  • ini_file: Which php.ini file to use; if null, use the default php.ini file.

  • ini_set: Override php.ini settings with these settings instead. The element key is the .ini setting name, and the element value is the .ini value to use.

  • solar_config: When calling Solar::start(), use this as the config value.

  • echo: Whether or not to echo the process output as it goes.

Constants

None.

Public Properties

The Solar_Php class has no public properties; try the list of all properties.

Public Methods

These are all the public methods in the Solar_Php class.

You can also view the list of all public, protected, and private methods.

__construct()

Constructor.

__destruct()

Default destructor; does nothing other than provide a safe fallback for calls to parent::__destruct().

addArgv()

Add a command-line argument for the code.

dump()

Convenience method for getting a dump the whole object, or one of its properties, or an external variable.

getExitCode()

Gets the exit code from the separate process.

getLastLine()

Gets the last line of output from the separate process.

getOutput()

Gets all lines of output from the separate process.

locale()

Looks up class-specific locale strings based on a key.

run()

Runs the named file as the PHP code for the process.

runCode()

Runs the given string as the PHP code for the process.

runSolar()

Runs a file as a Solar script.

runSolarCode()

Runs a code string as a Solar script.

setArgv()

Set all command-line arguments for the code at one time; clears all previous argument values.

setEcho()

Turns execution process output on and off.

setIniArray()

Sets an array of php.ini values, overriding the php.ini file.

setIniFile()

Sets the location of the php.ini file to use.

setIniVal()

Sets one php.ini value, overriding the php.ini file.

setPhp()

Sets the PHP command to call at the command line.

setSolarConfig()

When calling Solar::start() in the new process, use this as the $config value.



Local