Back-end processing in chrome extension - php

So I'm working on a chrome extension, which I'm pretty new to. I was wondering how exactly I can execute operations in this extension without having to host my own server. Basically, I'm trying to build an app that is going to interface with another website's API. The Google documents talk about how I can use html, css, and javascript in my extension, but in order to interface with this API, I would need to use something like PHP (which I know) or ruby (which I don't). But PHP only executes server side. It seems pointless to host a server just to do that, it should be possible to do client side. So basically, what's the procedure for building code (not HTML, CSS, or JS) to execute client side in a chrome extension, whether that be for working with an API or just for general processing? Languages like Java and Python work for this API too (not JS) but that seems like it would be more difficult to then reintegrate the information they return into the displayed HTML/CSS.
Sorry if that's a rambling question, I'm really new to this. Thanks in advance

Like you said, You won't be able to use PHP, Ruby or Java in the browser. You can only use JavaScript.
Why do you need server side client for the API? You may can do your call with JavaScript ? Otherwise you will need a sever.

Related

Can PHP be accessible offline?

My Employer would like me to take a web application written entirely in PHP to be accessible while offline. (it has to be accessible by an ipad without internet connection.)
I have tried the following things:
http://solesignal.com/draftcode/
http://blog.smartbear.com/codereviewer/15-code-editors-for-the-ipad-for-free-or-very-cheap/
https://itunes.apple.com/us/app/offline-pages-save-complete/id364859644?mt=8
Before I'm going to spend any money i have to be 100% positive it works.
Does anyone know how i can achieve this?
What do you mean by offline?
If you're looking to embed the server within your app, you're out of luck, it's not possible nor allowed. However if you want to run a local environment in your computer, take a look at MAMP
Knowing more about Mike's question, He's trying to run a website/webapp made in PHP offline/stand-alone on iOS devices.
As PHP is a pre-processor, this is not possible without a seperate server doing the magic. Depending on what this application has to do, I suggest you try to re-make the webapp so it does not use PHP. A lot of the things done with PHP can also be done client-side with JavaScript.
If you require more sophisticated things, try looking into the Meteor Framework. It supports PhoneGap exportation natively so the applications can run stand-alone on mobile devices as apps.
EDIT: If you can use an android device, you CAN run a PHP server on the same device as the pages are displayed because android is simply more open then iOS. If you're not willing to re-write the PHP code to JS, grab an android tab and use a PHP server package for android like this or another one that does include a MySQL server like this one

Using phonegap, is there a way for an Android device to communicate with PHP?

I have a php page which connects an API and gets information back which can then be displayed.
I'd like to turn this into an app for Android. I've heard of PhoneGap, which I know uses javascript, html, and css. I know javascript is capable of calling php files, but I am unsure how or if its even possible to call a php file from an android device. I'm not sure if android browsers can handle php, or what the deal is with them. So if you have any information on that, I'd appreciate it.
I'm also willing to rewrite the API call in javascript, but I don't think thats possible. If you think differently, please let me know what you're talking about.
Android cannot talk directly to PHP. What phonegap, javascript, etc.. are doing is simply issuing HTTP requests that happen to be handled by a PHP script.
The PHP code will execute, output some data (json, html, xml, gif, jpg, etc...) and send that out as a the HTTP request's reply.
PHP is just a server side language so it doesn't matter if your browser "can or cannot" handle it, only HTML is returned (unless you set a different content-type).
You may be worth while looking into REST style JSON api's which would allow a XMLRequest to be sent to. Have a look at this document
Theres also a nice tutorial here which shows how to call a REST API and a PHP Tutorial here to create a REST API.
1.It dosent matter to PhoneGap where the PHP is hosted or Its PHP OR ASP.NET OR ASP.NET MVC
2.If You wanna host your PHP code yourself in production (You mayb shouldn't do this in production). then you need a server and a static IP address
3.if you just wanna setup a PHP server for developmental purposes then just tie it to 127.0.0.1:81 and you can directly use this address it doesn't matter whether you have a static IP address or not.
I have done this with phonegap using jsonp
http://en.wikipedia.org/wiki/JSONP
Works great

Dreamweaver's build app function in cs 5.5 breaks if there is php code?

For javascript and html files only, Dreamweaver's build app for android function seems to work great in cs 5.5. But when any php code is put in (for authentication, or for ajaxing in web service returns ) it seems that the android app just displays broken php code instead of executing it. When building the app, Dreamweaver won't even let you use a root php file in the project; it only seems to only accept html files.
Am I doing something wrong? Building apps out of web language-based files seems a lot less useful if server-side code isn't allowed.
Are there any other alternatives? Titanium studio looks really complicated, but I'm willing to read the docs if it's worth the time.
http://help.adobe.com/en_US/dreamweaver/cs/using/WSeffff8bffc80208478c8d43312e240fe0ad-8000.html
Indeed it only packages HTML, CSS and Javascript into an Android or iOS package.
I'm afraid you'll have to learn real Android development if you want something more complex.
Dreamweaver will package the files up just like you asked, however, the destination system is what runs the code. Android doesn't execute the PHP within the app. Your app has to connect with a remote server that is to handle the log in. Thinks of two separate apps, one on the phone and one on your server.
Android doesn't execute the PHP within the app. This is because PHP is a server side client and Not client side. Unless they create some inbuit servers within phones from which native apps can tap into. One option you can use is to use html files and within them, create links to php files which are in online servers so as to have your scripts executed.

Server side SQLite database with Google Web Toolkit or JQuery

I have a large array of vehicle make and model data that I want to dynamically display on a web page. For example, when you select a vehicle make from a drop down menu the vehicle model dropdown is dynamically populated with an asynchronous call.
I would normally execute this with an AJAX call to a PHP script that would return the desired data from a server side database.
To remove the need for a PHP helper script, I would like to directly call a server side SQLite database.
Everything seems to indicate that server side SQLite databases are not meant to be queried with Google Web Toolkit or JQuery.
Is it possible to use a server side SQLite databases with Google Web Toolkit or JQuery?
Thanks as always!
a couple of datapoints:
both GWT and jQuery ultimately execute as JavaScript inside the browser. they don't have any access to the network stack beyond being able to initiate AJAX requests (HTTP).
SQLite isn't a server, it's a library embedded inside an executable. Most modern scripting languages (like PHP, Python, Ruby, etc) embed it in some library (either core or external).
both HTML5 and Google Gears use SQLite to provide client-side data storage to client-side JavaScript apps; but it's all running inside the browser and therefore fully client-side.
so.... there's no 'direct' route between GTW/jQuery to server-side SQLite
You might want to check out Google Gears. It integrates GWT and SQLite, so it might give you some clues and some sample code as to how this might work with an online application:
Google Gears is a library that enables
your web applications to work offline.
Currently it consists of three
modules: LocalServer for caching and
serving up your web app resources (ie.
html, javascript, images), a SQLite
Database for storing offline data, and
a WorkerPool for performing
asynchronous operations.
http://www.gwtsite.com/getting-started-with-gwt-and-google-gears/
There is a JDBC driver for SQLite, so you can provide (abstracted) access to this via GWT's RPC.

Notification message using php

I am developing an application in php. I need to display a notification message on windows taskbar. So please help me...How to do it using php.
With PHP, your domain is the web browser. You can display a message in the browser or in a pop up window. You can't connect to the operating system.
Probably PHPGTK can help you. But your question smells a bit, because as Sohnee mentioned PHP is made for creating web pages or things which are highly connected to the web.
However, it could help us if you provide much more information what you do, why you do it, and so on...
You could change the window title using ajax to display a message in the taskbar. That's as far as you can go using a webapp i think.
You might want to look for a Growl library. On Widows it would require some additional software. Google turns up:
http://forums.cocoaforge.com/viewtopic.php?f=6&t=16872
http://github.com/tylerhall/php-growl/tree/master
With C# for .NET you can easily write a notifier application which resides in the tray.
I just have written an XML based notifier application which communicates (XML data transfer) with a server that runs php. The IDE comes with a sample notifier application. If you are familiar with c# then go and get it.
It's open source
Goto SharpDevelopment IDE
What you can do, is develop a program that does this in another language, and then call it via system() in PHP.
Note that the notification will only pop up on the server. Since no actual PHP code is run on the client's machine.

Categories