some questions about phonegap

32 views
Skip to first unread message

Brett Reed

unread,
Nov 29, 2015, 6:15:45 PM11/29/15
to phonegap
Hello, I've used multiple app development methods and last night I found PhoneGap and it seems to be exactly what I've been looking for. But there's some concerns I have that I can't seem to find answers to. Maybe I'm not looking hard enough, but I figured I could post here, maybe someone could point me in the right direction.

When an app is compiled, built and ready to run on a device, are the assets and /www/ folder accessible and hidden within the app itself? If it is, how would I go about using server side scripting? Like PHP and mySQL. Is that even possible? Do I need to figure out how to store information on an html page rather than being sent to a server?
Or are the files stored over the internet and called upon when the app is run?
Or does the app act as a server?

For example of an app:
An app like instagram, I would need the app to access a server for storing of images, and for user log-ins/registration.

Also I hear a lot of reference to GitHub and Node.js. I'm really not sure what they're for. I have the PhoneGap standalone local server program for windows. And it seems to do what I need it to do. Besides compiling I haven't figured that out, but that's a later issue.

Any help? Thanks!

Rob Willett

unread,
Nov 30, 2015, 3:38:03 AM11/30/15
to phon...@googlegroups.com
Brett,

When you compile the app, the assets are stored in the app itself. These are not easily available to the untutored user but are not difficult to access if you know how. Assume that all your data and code is available unless you store it encrypted or in the keystone (for iOS). 

Server side scripting is done server side. You do NOT have access to PHP or MySQL directly on your phone, though you do have access to SQLite (a SQL database) on your phone though plugins. SQLite is an excellent SQL database and do not underestimate its power. It is the most widely used database in the world, though 99% of people never see it. You access the servers through whatever mechanism you wish, though AJAX POST and GET commands are normal. 

Your apps files are stored on the phone within the app itself. The app does not act as a server (unless you program it as such).

Writing Instagram requires considerable skills, I would advice you to start small and work out what you want to do then try and write larger apps.

Github is a publicly available versioning system. Google for for more information and has nothing specific to do with Coroda/PhoneGap. Node.js is also a different technology and is often used with Cordova on servers but again is not specific to PhoneGap.

Read the guides on the home page of this group for more information.

Rob.

--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
---
You received this message because you are subscribed to the Google Groups "phonegap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jcesarmobile

unread,
Nov 30, 2015, 3:47:04 AM11/30/15
to phonegap
Since cordova 3.0, it started to be distributed through npm (node package manager), so you need nodejs installed on your machine to install and use cordova
git is used to get some cordova components from github repositories, where the source code of that components is published (usually plugins)

Steve Husting

unread,
Nov 30, 2015, 10:58:04 AM11/30/15
to phonegap
My website is dedicated to newcomers to Cordova. (I follow these steps whenever I create a new app.) Read the first few articles here to set up on Windows, and learn how I create a Cordova App:
https://iphonedevlog.wordpress.com/workflow/

This article will help you understand the fundamentals:
https://iphonedevlog.wordpress.com/explanation-of-phonegapcordova-for-the-layman/

Kerri Shotts

unread,
Nov 30, 2015, 3:13:02 PM11/30/15
to phonegap
Inline:


On Sunday, November 29, 2015 at 5:15:45 PM UTC-6, Brett Reed wrote:
Hello, I've used multiple app development methods and last night I found PhoneGap and it seems to be exactly what I've been looking for. But there's some concerns I have that I can't seem to find answers to. Maybe I'm not looking hard enough, but I figured I could post here, maybe someone could point me in the right direction.

When an app is compiled, built and ready to run on a device, are the assets and /www/ folder accessible and hidden within the app itself?

App assets, both native and hybrid, are available on the device. Your www folder is also available and human-readable. You could encrypt the contents, but that's more trouble than it is worth (IMO) and you'd have to store that encryption key somewhere, which means a user is probably going to be able to figure it out anyway. In short: store no secrets in your local code!

[Side note: Native apps don't escape this either. I can read the assembly code for any native app I want. It's not as easy as reading JavaScript, obviously, but it's still possible.]
 
If it is, how would I go about using server side scripting? Like PHP and mySQL. Is that even possible? Do I need to figure out how to store information on an html page rather than being sent to a server?

Server side scripting is for the server, so you'll need the following setup:

    local code: HTML, JS, CSS using XHR/Sockets to communicate to your external server. Be sure to cache so that your app is usable offlline (if that makes sense for your app)
    webserver: PHP webservice accepting (and verifying) requests from your app's local code. Queries your MySQL database and returns appropriate results. Don't forget about SSL encryption! [and don't use self-signed certificates!]
    database server: mySQL backend. It's also possible that you might want SQLite on the local side for easy caching and such (there are third-party plugins for this), but you'll have to write sync/cache code yourself.

Your local code will be a single page web app. Single page is a misnomer, but it boils down to this: the app will only ever navigate to "index.html", and from there the contents of your DOM are managed by JavaScript (and are usually dynamic). You have access to local storage options (localStorage, IndexedDB, Web SQL via plugin, File API) and the network, but no access to other databases except via a webservice. 
 
Or are the files stored over the internet and called upon when the app is run?

You can do this, but you should maintain a local copy in case the app is offline. Apple will require that your app does something sensible when offline, even if only to generate a human-readable error.

Personally, my code is always stored locally, and my updates go through the normal process via the app stores. Others do differently and get by OK.

One thing you must be aware of, however, is that your app can't simply wrap an external website. Apple WILL reject your app. Make sure it uses at least some of the native capabilities of the device and you'll be fine.
 
Or does the app act as a server?

For example of an app:
An app like instagram, I would need the app to access a server for storing of images, and for user log-ins/registration.

Instagram's not trivial, and if you intend on creating the full stack, it's going to be quite the project. Might I suggest using a Backend-as-a-Service instead, like Parse? This way you don't have to worry about the database and backend security, and they have very easy-to-use SDKs for communication between the backend and client. In short, your images and user credentials would be sitting over at Parse, and you'd make simple SDK calls to retrieve data and upload new data.

Otherwise, you'll need something like I mentioned above (at least): a webservice that acts as an intermediary between your client and the database server and that properly validates incoming data, and a database server. Security on this is going to be a pain in the rear, especially since you are dealing with user credentials.
 

Also I hear a lot of reference to GitHub and Node.js. I'm really not sure what they're for.

Git is a code versioning system. GitHub is just one of many sites that host code repositories and enable social aspects (like forking, issues, wikis, etc.) You'll want to familiarize yourself with Git immediately -- although you don't have to know much about it, you should know how to version your code, and it will eventually save your ass down the line when you completely mess things up. I've been there, done that, and having Git versioning everything is wonderful.

[Note: If you version your code using another versioning system, that's fine. Just make sure you do it somehow.]

Note.js is a way to run JavaScript outside of the browser. It's used in server-side code much like PHP is. It also makes an ideal environment for creating cross-platform command-line utilities, which is why Cordova/PhoneGap CLI uses it.
 
I have the PhoneGap standalone local server program for windows. And it seems to do what I need it to do. Besides compiling I haven't figured that out, but that's a later issue.

If you're only ever going to upload to PhoneGap Build, this is all you absolutely need. If you ever intend on compiling locally, you'll need to install Node.js and the Cordova/Phonegap CLI (and appropriate SDKs).
 

Any help? Thanks!

Side note: you mention Windows -- if you intend on developing for iOS, you're going to need to get access to a Mac at some point! You can buy a Mac Mini or rent one in the cloud or just find a friend with one. Just something to think of. 

Hope that helps!
Reply all
Reply to author
Forward
0 new messages