Updated 2 years, 2 months and 2 days ago
Calling Talend Job from PHP Application
Table of Contents:
Talend allows us to export job script and call it from external java applications like eclipse or Netbeans. This procedure explains how to call a Talend job from PHP application.
In this article we will create a sample job which will print the two values like name and age on the console.
Here we will create a sample Talend job called CallJobFromPHPApplication with two components like tFixedFlowInput and tJavaRow.
Select the export type as Autonomous Job and save as archive file (.zip)
In eclipse, create a java application with the Project name as ‘PHP2Talend’
Right-click on the package and create a new java class with the name PHPTest.java to call Talend job.
Unzip the CallJobFromPHPApplication job to integrate Talend files into eclipse.
Right-click on the project root folder and select Build path, then select the Configure Build path option.
In the next window open Libraries tab and click on Add External Jars button to import all the required jar files.
Import below jar files from the CallJobFromPHPApplication directory.
1. Select calljobfromphpapplication_0_1.jar file from CallJobFromPHPApplication_0.1\CallJobFromPHPApplication directory.
2. Import below jar files from CallJobFromPHPApplication_0.1\lib directory.
Paste the copied directory into src folder as shown in the picture.
Open the PHPTest.java class in eclipse and edit it as follows.
Right - click on project root directory and click on export will display a new window, select Java->Runnable JAR File.
Select the launch configuration details from the dropdown and browse the export destination as show in the picture.
Now PHP2Talend.jar file has been created successfully.
>>Java –jar PHP2Talend.jar Java 12
Create a Php file callingTalend.php and edit the contents like below:
$cmd="java -jar C:\jars\PHP2Talend.jar"; $name="PHP"; $age ="10"; exec($cmd." ".$name." ".$age,$output); print_r($output); ?>
Copy this file under xampp/htdocs directory (Assuming that XAMPP already installed)
Go to browser and run callingTalend.php file like below: