如何将php&jqueryMobile应用程序转换为apk文件

问题描述 投票:4回答:1

我用PHP和jQuery mobile创建了一个应用程序,现在我正在寻找如何使用PhoneGap将此应用程序转换为apk文件。

是否有可能做到这一点?是否有任何教程可以帮助我学习如何做到这一点?

php jquery-mobile apk phonegap
1个回答
9
投票

这是一种快速简单的方法,如果你扩展到更真实的生活用途,那就更好了:

1-下载phonegap

2-使用this tutorial构建您的第一个应用程序或使用phonegap如何开始

3-一旦你有了让我们去服务器端......我们需要一个API,最简单的方法就是这样:

<?php
    header('Access-Control-Allow-Origin: *');
    header('Cache-Control: no-cache, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Content-type: application/json'); 

    if($_GET['nameofFunction'] == 'getHomepageContent'){
        require_once('controllers/homeController.php');
        $objHome = new homeController();
        $jsonReturn = $objHome->gethome();
        echo($jsonReturn);
    }
?>

4-创建该控制器以控制来自API的请求,例如:

   <?php
    class homeController {

        public function __contruct(){

        }


        public function gethome(){
            //do what ever you need here, sql query, errors handling.. and return it
                    //back to the api.
           //for example you could use something like this to return json array to the api
           // without making much effort 
         if(mysql_num_rows($yourquery) > 0){
                while($us = mysql_fetch_assoc($yourqueryResult)){
                    $output[]=$us;
                    $homeJsonResponse = json_encode($output);
                }

                return $homeJsonResponse;
        }
    }
    ?>

5-我们回到了phonegap应用程序,现在确保你包含所有需要的文件,jquery,jquerymobile,cordovajs,itouch,iscroll ....

6-创建将在加载时执行的函数并对api进行ajax调用,这将返回json,just parse with jquery,你很高兴。

© www.soinside.com 2019 - 2024. All rights reserved.