I recently had someone ask me to provide an example using PHP with the SolidWorks EPDM API. I am posting the example I provided in hopes it may help someone else down the road.
Note the module name in the ‘new COM’ line.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
p, table {font-family: verdana,arial,sans-serif;}
table.gridtable {font-size:11px; color:#333333; border-width: 1px; border-color: #666666; border-collapse: collapse;}
table.gridtable th {border-width: 1px; padding: 8px; border-style: solid; border-color: #666666; background-color: #dedede;}
table.gridtable td {border-width: 1px; padding: 8px; border-style: solid; border-color: #666666; background-color: #ffffff;}
</style>
</head>
</body>
<?php
$vault = new COM('ConisioLib.EdmVault');
$vault->Login('lyoung','password','vaultName');
if($vault->IsLoggedIn) {
$VerMajor = 0;
$VerMinor = 0;
$vault->GetVersion($VerMajor,$VerMinor);
echo "<p>";
echo "<br />PDM version: " . $VerMajor . "." . $VerMinor;
echo "<br />Vault name: " .$vault->Name;
$RootFolder = $vault->RootFolder;
echo "<br />Root folder local path: " .$RootFolder->LocalPath;
echo "</p>";
echo "<table class='gridtable'><tr>";
echo "<th>Filename</th><th>Local path</th><th>Lock path</th><th>Current State</th><th>Config. count</th></tr>";
$FilePos = $RootFolder->GetFirstFilePosition();
while($FilePos->IsNull == false)
{
echo "<tr>";
$lParentFolderID = $RootFolder->ID;
$File = $RootFolder->GetNextFile($FilePos);
echo "<td>" . $File->Name . "</td>";
$pbsRetPath = $File->GetLocalPath($lParentFolderID);
echo "<td>" . $pbsRetPath . "</td>";
echo "<td>" . $File->LockPath . "</td>";
echo "<td>" . $File->CurrentState->Name . "</td>";
$VersionNo = 0;
$Configs = $File->GetConfigurations($VersionNo);
echo "<td>" . $Configs->Count . "</td>";
echo "</tr>";
}
echo "</table>";
}
else {
echo "<br />Not logged in!";
}
?>
</body>

Hi There! I’m looking at tapping into EPDM from php a little bit. I’ve tried this example and the table comes out blank.
It gives me a local folder reference and version correctly, so I know it connects.
Not sure what I am doing wrong.
Also, any idea how to use GetVaultViews in php?
Cory, it may be that where you’re running the code you don’t have a local version of the file. That’s all I can think of. I haven’t used PHP in years, so I won’t be much help to you at the moment. I can look into it, but it would take me a while.