Home > Backend Development > PHP Tutorial > A new life for hybrids--Java+PHP integration_PHP tutorial

A new life for hybrids--Java+PHP integration_PHP tutorial

WBOY
Release: 2016-07-13 17:44:34
Original
1643 people have browsed it

Only recently have I had time to work on this and apply this idea to a real-world application. The following explains how to develop and publish from two aspects.
Example: Explain the java+php development model, taking menu management as an example.
An example is as follows:
1: java structure code
The java development structure diagram is as follows:

java 开发结构图

For the java program code, please see the uploaded file below. Since the uploaded file cannot be larger than 2M, the lib used is not uploaded. If you need it, please leave your email to me and I will send it to everyone.
Note: PHP and Java each have data types defined within their own languages. When PHP data is transmitted to Java, or Java data is transmitted to PHP, LAJP automatically and accurately converts them internally, and programmers do not need to perform any decoding. Work
2: Java application release
Place the compiled files in the LAJP directory: My file directory: E:lajp-10.05test_serviceecard
As shown below:

A new life for hybrids--Java+PHP integration_PHP tutorial

三:php 结构代码
class Menu extends CI_Controller{
 
 function __construct(){
  parent::__construct();
  $this->load->model('system/menu_model');
 }
 
 function index(){
  $condition = array();
  $condition['menu_id'] = $this->uri->segment(4,0);
  $condition['path'] = $this->input->post('path');
  $condition['start'] = $this->input->post('start');
  $condition['id'] = $this->input->post('id');
  $condition['order'] = $this->input->post('order');
  $condition['isfresh'] = $this->input->post('isfresh');
  $condition['visible'] = $this->input->post('visible');
  $condition['defaultselect'] = $this->input->post('defaultselect');
  $condition['name'] = $this->input->post('name');
  $condition['parentid'] = $this->input->post('parent_id');
  $condition['numPerPage'] = $this->input->post('numPerPage') ? $this->input->post('numPerPage') : 20;
  $condition['orderField'] = $this->input->post('orderField') ? $this->input->post('orderField') : 'SMT_PARENT_ID';
  $condition['pageNum'] = $this->input->post('pageNum') ? $this->input->post('pageNum') : 1;
  $data = array();
  $allmenus = $this->menu_model->getMenus();
  $this->load->library('smart_tree');
  $options = array(
   'index'   => 1,
   'type'   => 0,
   'self'    => 1,
   'hreffromdb' => 0,
   'relfromdb'  => 0,
   'rel'   => 'system/menu/index',
   'href'   => 'system/menu/index/',
   'hrefuseid'  => 1,
   'title'   => '菜单管理'
  );
  $data['allmenus'] = $this->smart_tree->getTrees($allmenus, $options);
  $data['menus'] = $this->menu_model->getMenusVoByCondition($condition);
  $data['total'] = $this->menu_model->getCount($condition);
  $data['condition'] = $condition;
  $this->load->view('system/menu/index.phtml', $data);
 }
 
 function add(){
  $data['menus'] = $this->menu_model->getMenus();
  $this->load->view('system/menu/add.phtml',$data);
 }
 
 function insert(){
  $vo = newObject('ecard_sys_menus_vo_MenusVo');
  $vo->name = (string)$this->input->post('name');
  $vo->parentid = (int)$this->input->post('parent_id');
  $vodefaultselect = (int)$this->input->post('defaultselect');
  $vo->visible = (int)$this->input->post('visible');
  $vo->isfresh = (int)$this->input->post('isfresh');
  $vo->desc = (string)$this->input->post('desc');
  $vo->path = (string)$this->input->post('path');
  $vo->start = (int)$this->input->post('start');
  $vo->order = (int)$this->input->post('order');
  $vo->cuser = 1;
 
  if($this->menu_model->insert($vo)){
   $reback = array("statusCode"=>"200","message" => "添加成功","navTabId" => "system/menu/index", "callbackType" => "closeCurrent","forwardUrl" => "" );
  }else{
   $reback = array("statusCode"=>"300","message" => "添加失败","navTabId" => "", "callbackType" => "","forwardUrl" => "" );
  }
  echo json_encode($reback);
 }
 
 function edit(){
  $menu_id = $this->uri->segment(4,0) or exit('菜单不存在');
  $data['menu'] = $this->menu_model->getMenusVoById($menu_id) or exit('菜单不存在');
  $data['pmenu'] = $this->menu_model->getMenusVoById($data['menu']['parentid']) or exit('菜单不存在');
  $this->load->view('system/menu/edit.phtml',$data);
 }
 
 function update(){
  $vo = newObject('ecard_sys_menus_vo_MenusVo');
  $vo->id = (int)$this->input->post('id');
  $vo->name = (string)$this->input->post('name');
  $vo->path = (string)$this->input->post('path');
  $vo->parentid = (int)$this->input->post('parent_id');
  $vo->order = (int)$this->input->post('order');
  $vo->start = (int)$this->input->post('start');
  $vo->defaultselect = (int)$this->input->post('defaultselect');
  $vo->visible = (int)$this->input->post('visible');
  $vo->isfresh = (int)$this->input->post('isfresh');
  $vo->desc = (string)$this->input->post('desc');
  $vo->uuser = 1;
  if($this->menu_model->update($vo)){
   $reback = array("statusCode"=>"200","message" => "编辑成功","navTabId" => "system/menu/index", "callbackType" => "closeCurrent","forwardUrl" => "" );
  }else{
   $reback = array("statusCode"=>"300","message" => "编辑失败","navTabId" => "", "callbackType" => "","forwardUrl" => "" );
  }
  echo json_encode($reback);
 }
 
 function delete(){
  $ids = $this->input->post('ids');
  if(!$ids){
   $ids = $this->uri->segment('4',0) or exit('缺少参数');
  }
  if($this->menu_model->deletes($ids)){
   $reback = array("statusCode"=>"200","message" => "删除成功","navTabId" => "", "callbackType" => "","forwardUrl" => "" );
  }else{
   $reback = array("statusCode"=>"300","message" => "删除失败","navTabId" => "", "callbackType" => "","forwardUrl" => "" );
  }
  echo json_encode($reback);
 }
 
 function search(){
  $data = array();
  $data['menus'] = $this->menu_model->getMenus();
  $this->load->view('system/menu/search.phtml',$data);
 }
 
 function tree(){
  $menus = $this->menu_model->getMenus();
  $this->load->library('smart_tree');
  $data['menus'] = $this->smart_tree->getTrees($menus,array('index'=>1,'type'=>0,'self'=>1,'hreffromdb'=>0));
  $this->load->view('system/menu/tree',$data);
 }
 
}
四:应用展现
        java程序开发完成后,并将编译后程序发布到lajp文件目录下后,点击E:lajp-10.05下的run-socket.bat 运行程序,如下图所示:

A new life for hybrids--Java+PHP integration_PHP tutorial

A new life for hybrids--Java+PHP integration_PHP tutorial:

A new life for hybrids--Java+PHP integration_PHP tutorial

The php interface is shown as follows:
Application interface

A new life for hybrids--Java+PHP integration_PHP tutorial
This article comes from the blog "Bragging about pulling submarines and pushing trains and planes"

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478731.htmlTechArticleOnly recently have I had time to deal with this matter and apply this idea to real-world applications. The following explains how to develop and publish from two aspects. Example: Explain the java+php development model and use menu management...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template