reksss Posted November 7, 2011 Share Posted November 7, 2011 Hello Friends, Im trying to connect Perforce from Linux. I want to get(sync) file from perforce, then need to edit and submit it back to perforce.... Do you guys have any sample codings to do so?? Waiting for ur reply, Thanks Rekha Quote Link to comment https://forums.phpfreaks.com/topic/250600-do-anybody-know-how-to-write-php-script-for-connecting-perforce/ Share on other sites More sharing options...
trq Posted November 7, 2011 Share Posted November 7, 2011 There appears to be a PECL extension for such tasks. http://www.indelible.org/php/perforce/guide.html Quote Link to comment https://forums.phpfreaks.com/topic/250600-do-anybody-know-how-to-write-php-script-for-connecting-perforce/#findComment-1285786 Share on other sites More sharing options...
reksss Posted November 7, 2011 Author Share Posted November 7, 2011 Hello.... If i run this program i got the below error msg. Run -> edit successfully [P4.run()] Errors during command execution( "p4 submit -r" ) [Error]: No files to submit from the default changelist. Error: No files to submit from the default changelist. <?php $p4 = new P4(); $input_file = "//Consumer/WSE/Dev/SSO-1.0/SSO/QA/edit.txt"; //*********** Connect to Perforce ************************************* $p4->port = "tw-p4proxy.tw.trendnet.org:1667"; $p4->user = "***"; $p4->client = "WSE_QA_tw-rekha"; $template = "WSE_QA_tw-rekha"; $client_root = "C:/Users/rekha_sokiyan/WSE_QA_tw-rekha"; $client_name = "WSE_QA_tw-rekha"; $p4->connect(); $p4->run_login('******' ); try { //*************** SYNC ******************************************** $p4->exception_level = 1; // Convert client spec into an array $client = $p4->fetch_client("-t", $template); $client['Root'] = $client_root; //print_r($client); $p4->save_client($client); // File(s) up-to-date is a warning; no exception raised if($p4->run_sync($input_file)) echo "\nRun -> sync successfully\n"; //**************** EDIT ******************************************** if($p4->run("edit",$input_file)) echo "\nRun -> edit successfully\n"; $p4->client; //*************** SUBMIT ******************************************* $change = $p4->fetch_change(); // Files were opened elsewhere and we want to submit a subset that we already know about. $myfiles = array( '//Consumer/WSE/Dev/SSO-1.0/SSO/QA/edit.txt', '//Consumer/WSE/Dev/SSO-1.0/SSO/QA/test.txt' ); $change['Files'] = $myfiles; $p4->input = $change; $p4->change = $change; $change['Description'] = "My changelist\nSubmitted from P4PHP\n"; //print_r($change); $p4->run_submit("-r",$change); $spec = $p4->fetch_change(); $spec["Description"] = "My changelist\nSubmitted from P4PHP\n"; //$p4->run_submit($spec); //print_r($spec); //if($p4->run_submit("-i",$change)) // echo "\nRun -> Submitted from P4PHP\n"; //**************** EDIT ******************************************** if($p4->run("edit",$input_file)) echo "\nRun -> edit successfully\n"; $p4->client; //*************** SUBMIT ******************************************* $change = $p4->fetch_change(); // Files were opened elsewhere and we want to submit a subset that we already know about. $myfiles = array( '//Consumer/WSE/Dev/SSO-1.0/SSO/QA/edit.txt', '//Consumer/WSE/Dev/SSO-1.0/SSO/QA/test.txt' ); $change['Files'] = $myfiles; $p4->input = $change; $p4->change = $change; $change['Description'] = "My changelist\nSubmitted from P4PHP\n"; //print_r($change); $p4->run_submit("-r",$change); }catch (P4_Exception $e) { print $e->getMessage() . "\n"; foreach ($p4->errors as $error) { print "Error: $error\n"; } } ?> [code] Do anybody help me to fix it? Quote Link to comment https://forums.phpfreaks.com/topic/250600-do-anybody-know-how-to-write-php-script-for-connecting-perforce/#findComment-1285788 Share on other sites More sharing options...
trq Posted November 7, 2011 Share Posted November 7, 2011 I know nothing of perforce or the extension I linked you too, sorry. Quote Link to comment https://forums.phpfreaks.com/topic/250600-do-anybody-know-how-to-write-php-script-for-connecting-perforce/#findComment-1285789 Share on other sites More sharing options...
reksss Posted November 7, 2011 Author Share Posted November 7, 2011 Hello, I checked the link which has mentioned above. I was totally different while comparing with my coding... Will u help me to fix the bug? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/250600-do-anybody-know-how-to-write-php-script-for-connecting-perforce/#findComment-1285790 Share on other sites More sharing options...
reksss Posted November 7, 2011 Author Share Posted November 7, 2011 Hey i missed to tell something. If u do any changes in the browser, the file need to call, edit and submit automatically in the perforce... Quote Link to comment https://forums.phpfreaks.com/topic/250600-do-anybody-know-how-to-write-php-script-for-connecting-perforce/#findComment-1285792 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.