Coder Social home page Coder Social logo

php-ibmi's Introduction

IBM i extension for PHP

This extension allows PHP programs to access IBM i specific facilities, such as:

  • Run CL scripts directly, and get their output, using similar interfaces that already exist for system, exec, and passthru
    • This allows running CL scripts in the context of the process; for example, CHGJOB will actually apply to the current job.
  • Get the current job and PASE CCSID, get the CCSID of files

While some of this was possible before, it required workarounds like calling into QSH or the FFI extension (which may be restricted). Some of it wasn't even possible at all.

Documentation

CCSID functions

int ibmi_get_pase_ccsid()

Returns the current ASCII/PASE CCSID for the job.

int ibmi_get_job_ccsid()

Returns the current EBCDIC/job CCSID.

File functions

array|false ibmi_stat(string $filename)

Returns an array with entries codepage, ccsid, and objtype. Their values are equal to the st_objtype, st_codepage, and st_ccsid values returned by ILE stat.

Similar to the PHP function stat.

CL commands

These execute CL commands in the context of the job.

The command is run with the PASE function systemCL. The output is captured and read out in a separate file descriptor.

Flags that can be given to change behaviour are:

  • IBMI_CL_SPAWN: A new job is spawned for the CL.
  • IBMI_CL_NO_MESSAGES: Skip printing out IBM i messages i.e. "CPF0000".
  • IBMI_CL_EBCDIC_OUTPUT: Do not convert output from EBCDIC (assumed) to ASCII/Unicode.

string|false ibmi_cl_system(string $command, int $flags = 0)

Executes and prints output to stdout, while returning the last line as a string.

Equivalent to the PHP function system.

?bool ibmi_cl_passthru(string $command, int $flags = 0)

Executes and prints output to stdout.

Equivalent to the PHP function passthru.

string|false ibmi_cl_exec(string $command, int $flags = 0, array &$output = null)

Executes and returns the last line as a string.

If $output is set, the array will be filled with each line of the output.

Equivalent to the PHP function exec.

Licensing

Please see LICENSE; this extension uses code from PHP and thus is kept under the same license. Some files may be licensed under different, compatible licenses; this will be marked in the header.

Requirements

  • PHP 7.3 or newer
  • IBM i 7.2 or newer

Building

There are no additional build options.

phpize --clean
phpize
# You may need to specify the build manually because autotools doesn't recognzie os400
./configure --prefix=$PREFIX --build=powerpc-ibm-aix
# libtool may only generate an .a file in modules, so force .so
make && cp .libs/ibmi.so modules/
make install

Future plans

It would be useful to integrate other IBM i extensions, particularly those that do upcalls; such as the ones for authentication and XMLSERVICE fast paths. Such fast paths could benefit the Toolkit, in particular, if it provides enough of a performance benefit.

Perhaps generic IBM i FFI could be considered, but this is a bit of a risk. It would have to be disabled by default.

php-ibmi's People

Contributors

nattynarwhal avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.