Documentation:Reference:Php - MdsWiki
Navigation
Personal tools

From MdsWiki

Jump to: navigation, search

To build the MDSPLUS PHP extension you should perform the following steps. Beginning with downloading the sources.

Download MDSplus sources

The MDSplus source code is maintained on github. If you are interested in building MDSplus from the sources we recommend downloading a tarball, or a zip file from there.

  1. choose 'stable' or 'alpha' - ""note alpha is the active development branch and may contain untested code.""
  2. choose 'zip' or 'tar.gz'
  3. download the sources (choose one of):
    wget https://github.com/MDSplus/mdsplus/archive/alpha.zip
    wget https://github.com/MDSplus/mdsplus/archive/alpha.tar.gz
    wget https://github.com/MDSplus/mdsplus/archive/stable.zip
    wget https://github.com/MDSplus/mdsplus/archive/stable.tar.gz

The MDSplus repository can also be cloned from github using:

git clone https://github.com/MDSplus/mdsplus.git

Steps

  1. Download the source distribution for PHP. (This extension has only been tested on PHP Version 4.3.7 on RHE Linux.)
  2. Create an mdsplus subdirectory in the ext directory of the PHP source kit.
  3. Copy the files in the mdsplus/php directory to this new mdsplus directory.
  4. Configure the PHP build
    In the top of the PHP source directory tree run the configure script using
    ./configure --with-mdsplus=/usr/local/mdsplus (or the directory where you have mdsplus installed)
    Note: You may want to use additional configure options to build additional modules as needed or to add the new php into your apache server.
  5. Build and install php
    make
    make install
  6. Try out the MDSplus php interface
php < PHP_SOURCE_DIR/ext/mdsplus/sample.php 

If you want to just build a loadable module for php you can do the following:

cd PHP_SOURCE_DIR/ext/mdsplus
./build.sh 

This should produce a mdsplus_php.so loadable module. You would use the dl() function to load this module. Note the location that the dl() function uses to find loadable modules is set in the php.ini configuration file. This may, by default, be set to "./" which would require the module to be located in the same directory as the php script being executed.

Another method is to use the phpize program which is often distributed with php. To use this method do the following commands:

$ cd mdsplus/php     (This is the php directory under the mdsplus source tree)
$ phpize
$ ./configure
$ make 

This will produce a modules/mdsplus.so file which you can copy to mdsplus_php.so in your php library directory.

There are several sample php cgi scripts found in the php subdirectory of the mdsplus source tree:

sample.php - shows most of the use and functionality of the php interface.
shot_display.php - displays plots of mdsplus signals.
browser.php - a simple mdsplus tree browser