如何转换 php &jqueryMobile 应用到 apk 文件 [英] How to convert php & jqueryMobile application to apk file

查看:57
本文介绍了如何转换 php &jqueryMobile 应用到 apk 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 PHP & 制作了一个应用程序jQuery mobile,现在我正在寻找如何使用 PhoneGap 将此应用程序转换为 apk 文件.

I made an application with PHP & jQuery mobile, and now I'm looking for how to convert this application to an apk file using PhoneGap.

可以这样做吗?是否有任何教程可以帮助我学习如何操作?

Is it possible to do this? And are there any tutorials to help me learn how to do it?

推荐答案

这是一个快速而简单的方法,如果你扩展到更多的现实生活中会更好:

This is a fast a simple way to do it, it is better if you extended to make more real life usage:

1- 下载 phonegap

2- 使用 本教程 或使用phonegap 如何开始使用

2- Build your first app using this tutorial or using the phonegap how to get stared

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

3- once you have that let's go server side.. we need a API, the simplest way to do this is like this:

<?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 的请求,例如:

4- create that controller to control the request from the API, for example something like this:

   <?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....

5- We are back to the phonegap application, now make sure you are including all needed files, jquery, jquerymobile, cordovajs, itouch, iscroll....

6- 创建将在加载时执行的函数并对 api 进行 ajax 调用,这将返回 json,只需解析使用 jquery,你就可以开始了.

6- create the function that will execute on load and make the ajax call to the api, this will return json, just parse with jquery, and you are good to go.

这篇关于如何转换 php &amp;jqueryMobile 应用到 apk 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆