Currently in the proof of concept phase but I think this could be used to convert File Members to stream files so they could be used to check into a git repository.

Changes to the source file will hopefully kick off the trigger, which will then call CL program to call the PHP script to pull down all the file’s members into stream files.  Then its in the developer’s hand to run git on the files.  I’ve also considered creating an automated job that would auto-commit an auto-update the git repo so the code would always be checked in and know one would need to do the commits and updates.

CALL PGM(QP2SHELL) PARM('/usr/local/zendsvr/bin/php-cli batchphp/CopyMembersToStreamFiles.php')

<?
$lib = "MYLIB"; //The library the file members are in
$file = "QRPLESRC"; // The file the file members are in
$outfile = "$lib/ALLMEMBERS"; // The output file that contains all the members of $lib/$file after the DSPFD command is ran
$membersArray = array();
//Comment line below if you want to hardcorde the members you want to pull
//$membersArray = array('MyMember1','MyMember2','MyMember3');
//Below will take all members under $lib/$file and put it into the output file $lib/$outfile
//::Alternative:: user OVRDBF or Create Alias over every member file http://www-01.ibm.com/support/docview.wss?uid=nas8N1018261
$toolkit->runCL("DSPFD FILE( $lib/$file ) TYPE( *MBR ) OUTPUT(*OUTFILE) OUTFILE( $lib/$outfile )");
//read the outputfile to get the file members
$outfilecontent = readfile("$lib/$outfile");
//parse $outfilecontent to get all the members in $file
foreach($outfilecontent as $line) {
$membersArray[] = $line ;
}
//PHP IBMi toolkit that lets you call CL
$toolkit = new IBMiToolkit();
//loop through each file member and copy it to a stream file using CPYTOSTMF
foreach($membersArray as $srcmember)
{
$toolkit->runCL("CPYTOSTMF FROMMBR('/QSYS.LIB/$lib.LIB/$file.FILE/$srcmember.MBR') TOSTMF('$srcmember.TXT') STMFCCSID(1208)");
}
// Ending message that the process has worked and completed.
echo "I'm done copying Source Members to stream files";

ADDPFTRG FILE(MYLIB/QRPLESRC) TRGTIME(*AFTER) TRGEVENT(*INSERT) PGM(MYLIB/ConvertAllMembersToStreamFiles)
ADDPFTRG FILE(MYLIB/QRPLESRC) TRGTIME(*AFTER) TRGEVENT(*UPDATE) PGM(MYLIB/ConvertAllMembersToStreamFiles)

difference between PC file structures and AS400/IBMi Difference between PC file structures and AS400/IBMi