Continuous Integration for PHP Extensions
/0 Comments/in Open Source, PHP /by Calvin Buckley(Co-written with Alan Seiden)
Continuous Integration (CI) ensures that every time a developer commits changes to a version control system such as Git, the code is automatically built and subjected to automated tests.
CI has been invaluable to us. As maintainers of PHP’s PDO_IBM and ibm_db2 extensions, we use CI to ensure high quality across platforms.
Platforms supported by PHP’s extensions for Db2 include IBM i, Unix/Linux, and Windows. While our focus is IBM i, we must ensure compatibility with the others. Reliance on manual testing would introduce the risk of broken builds or subtle bugs. Automation is a must.
In this post, we explain how we use CI principles when building and testing PHP’s Db2 extensions.
Visual Studio Code, IBM i & PHP
/0 Comments/in PHP, VS Code for i /by Liam Barry Allan
Every post about Code for IBM i thus far has been how it can be used for writing RPG, CL, COBOL, etc. But what about other languages? Of course, PHP is another one of those very popular languages on IBM i. Calvin wrote a little while ago about how it’s possible to use RDi to write PHP code on the server, which is great. I think we can take it up a notch, which brings us to this post.
Detecting Memory Leaks in PHP Extensions During Development
/4 Comments/in PHP /by Calvin Buckley
When a PHP extension has a memory leak, mysterious crashes can result, forcing users to restart the web server for relief.
As official maintainers of the ibm_db2 and PDO_IBM extensions, we’ve been on a quest to find and eliminate any memory leaks from these popular PHP modules.
With such a comprehensive goal, we needed a strategy. For extensions that have comprehensive test suites we decided that, in addition to reviewing the usual regression tests, why not also use the tests to detect leaks?
What follows is a technical look at how we do it.
Sending Email from PHP on IBM i
/0 Comments/in PHP /by Calvin BuckleyWith reliable email functionality being one of the top concerns of IBM i PHP users, we’ve made sure that Seiden PHP+ includes everything you need to send email. The PHP mail() function works well, as do components such as Zend\Mail and PHPMailer.
Over the past couple of years, we’ve been hearing from disappointed PHP users that mail() didn’t work in other community PHP distributions (and some builds of Zend Server). PHP mail() requires an external program that implements the sendmail interface. If your PHP distribution lacked sendmail or equivalent, you might have received a cryptic error message such as:
|
1 |
sh: -t: not found |
This article discusses your options for sending email using Seiden PHP+.
Q&A: IBM i ODBC Driver
/4 Comments/in ODBC, Open Source, PHP /by Alan Seiden
I recently caught up with Seiden Group CTO Stephanie Rabbani about the ODBC driver that’s quickly becoming standard for open source and web connections on Db2 for i.
Free PHP on IBM i: from Basic edition to RPMs
/0 Comments/in PHP /by Alan SeidenUPDATE: Community PHP is now known as Seiden PHP.
Last week, Perforce announced plans to withdraw Zend Server for IBM i “Basic” by June 2021. Filling the gap is “community” PHP for IBM i, installable in RPM format.
Seiden Group has been assisting IBM i clients to adopt Community PHP since its introduction last year. We’ve helped with both first-time PHP installations and migrations from Basic.
Calling procedures and service programs with the PHP Toolkit for IBM i
/14 Comments/in IBM i, PHP /by Alan SeidenCalling procedures in RPG service programs, including getting the return value, is a powerful feature of the PHP Toolkit. The sample script below demonstrates how it’s done.
Note: Make sure your procedure name is 100% correct. It is case-sensitive. If you get an error, run the following command (replacing LIBNAME/PGMNAME with your library and program names) and look for your procedure name in the output. The command:
DSPSRVPGM SRVPGM(LIBNAME/PGMNAME) DETAIL(*PROCEXP)
The example below includes ‘boilerplate’ code to show best practices for connecting to the toolkit and checking for a successful connection. The illustration of how to call a procedure is in the second half.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
<?php require_once('ToolkitService.php'); // connect to toolkit using DB2 credentials (can also leave blank for default authority) try { $conn = ToolkitService::getInstance('*LOCAL', 'MYUSER', 'MYPASS'); } catch (Exception $e) { // Determine reason for failure. // Probably database authentication error or invalid or unreachable database. $code = $e->getCode(); $msg = $e->getMessage(); switch ($code) { case 8001: // "Authorization failure on distributed database connection attempt" // Usually means a wrong DB2 user or password echo 'Could not connect due to wrong user or password.'; break; case 42705: echo 'Database not found. Try WRKRDBDIRE to check.'; break; default: echo 'Could not connect. Error: ' . $code . ' ' . $msg; break; } //(switch) die; // couldn't connect...handle this however you wish } //(try/catch) // set stateless mode for easy testing (no 'InternalKey' needed). // (setOptions() introduced in v1.4.0) $conn->setOptions(array('stateless'=>true)); /* If you wish to test this script but you don't have a real service program, * use parseOnly and parseDebugLevel as shown below. * No program will be called and you'll get your original values back. * Simply uncomment the next line to try this great testing feature of the toolkit. */ //$conn->setOptions(array('parseOnly'=>true, 'parseDebugLevel'=>1)); // define several input/output params $params = []; // start with empty array $params[] = $conn->AddParameterChar('in', 1,'Division', 'DIV', 'A'); $params[] = $conn->AddParameterChar('in', 6,'Product', 'PROD', '123456'); $params[] = $conn->AddParameterPackDec('both', 7, 2, 'Quantity', 'QTY', '4.53'); $params[] = $conn->AddParameterZoned('out', 5, 2, 'Price', 'PRICE', '0'); // define a procedure return param. Can be any type, even a data structure $retParam = $conn->AddParameterInt32('out', '4-byte int', 'MYRESULT', '13579'); /* Call service program procedure. * In this example, assume your program is MYLIB/MYPGM and has a procedure/function 'myproc' * (procedure name is case-sensitive). * Note: specify optional procedure name in parameter 5, an array with associative index 'func'. */ $result = $conn->PgmCall('MYPGM', 'MYLIB', $params, $retParam, array('func'=>'myproc')); if (!$result) { echo 'Error calling program. Code: ' . $conn->getErrorCode() . ' Msg: ' . $conn->getErrorMsg(); } echo 'Called program successfully.<BR><BR>'; echo 'Input/output params: QTY: ' . $result['io_param']['QTY'] . ' PRICE: ' . $result['io_param']['PRICE'] . '<BR>'; echo 'Procedure return param MYRESULT: ' . $result['retvals']['MYRESULT']; /* The above will output something like: Called program successfully. Input/output params: QTY: 4.53 PRICE: 0.00 Procedure return param MYRESULT: 13579 */ |
For more information on the toolkit, see our toolkit information page or get in touch.
ZF2 and DB2 for IBM i
/11 Comments/in Db2 for i, IBM i, Open Source, PHP /by Alan SeidenI’d like to address questions about DB2 support in Zend Framework 2.x. Because I helped create the IBM i-friendly DB2 adapter for Zend Framework 1.x, I’ve followed the development of a similar adapter for ZF2.
(updated January 30, 2013, upon the release of ZF 2.1)
Q. Does ZF 2 include an adapter for DB2?
A. Yes! Starting with ZF 2.1, which was released today.
Q. Is Alan’s IBM i-friendly DB2 adapter for Zend Framework 1.x needed in 2.x?
A. No. Because ZF’s Zend_Db equivalent in 2.x works differently than in 1.x, my 1.x component is not needed in 2.x.
Q. Does ZF 2.1’s DB2 adapter work with IBM i?
A. Yes! Please try it and provide feedback to the ZF team.
PHP on IBM i (and me) at ZendCon 2009
/0 Comments/in IBM i, PHP /by Alan SeidenThis year’s ZendCon (Oct. 20-22, 2009, in San Jose, Calif.), the premier PHP conference, features several presentations about developing with PHP on the IBM i, including one by me!
Come hear me speak about “Zend Framework for Enterprise PHP on IBM i” on Tuesday, Oct. 20, 2009, at 4pm.
For details, go to http://www.zendcon.com.
SEIDEN GROUP: Modern Development & Open Source for IBM i
Home | Seiden PHP+ | IBM i Services | Support | VS Code for i | Free Stuff | Blog | Privacy Policy | Contact 201.447.2437

