6

I have to develop an application for a gas agency where a database will store consumer numbers, names, addresses, and date delivered for a town with nearly 20,000 people. I only know PHP, MySQL, CSS, jQuery, and other web based technologies. Is it possible to deliver a package to the client using these technologies that can be installed on a computer and used locally?

This application will run on a single PC for a single user. I'm familiar with tools such as XAMPP, but I do not want to run a web server locally. Both the application and database will be securely running on a particular computer. In the future, if this application must be on multiple computers, I want the database and application to be portable.

I have searched for similar questions on Stack Overflow and I did find some recommendations like Jetty, Adobe Air and the recent Web SQL database. Is PHP GTK also a viable tool for building professional applications?

I would like a recommendation specific for this kind of app.

11
  • 1
    Why not build a local web application?
    – yannis
    Feb 5, 2012 at 6:34
  • 3
    @Yannis okay , but why a downvote ?
    – HalfWebDev
    Feb 5, 2012 at 6:47
  • 4
    How should I know?
    – yannis
    Feb 5, 2012 at 6:49
  • @YannisRizos sorry , i thought it was you .
    – HalfWebDev
    Feb 5, 2012 at 6:51
  • 3
    PHP GTK is essentially a dead project. Go to their web site and check out when the last time there was any activity was...
    – yannis
    Feb 5, 2012 at 11:47

7 Answers 7

3

EDIT. There is a binary release of PHP Desktop with Internet Explorer engine ready, go download it at:

http://code.google.com/p/phpdesktop/


(read "SUMMARY" for a newbie explanation)

In short:

  1. Host a WebBrowser control in a simple c++ app.

  2. Call ShellExecute() to run php 5.4.0 builtin webserver.

  3. Use sqlite as your database.

In details:

  1. Create a simple win32 application that hosts WebBrowser control, for example with C++ and MFC:

    http://msdn.microsoft.com/en-us/library/ie/aa752046(v=vs.85).aspx

    This can all be done using simple wizards, you don't need to know C++ or anything, but you have to install VisualStudio, then run the wizard and change the path that is on this line:

    m_browser.Navigate("127.0.0.1:1234", NULL, NULL, NULL, NULL);

    (that navigate call should really happen after step 2. - when you have php server running)

  2. You need to add another line in your c++ program, a call to ShellExecute() that will start the php 5.4.0 builtin server.

    ShellExecute() docs at MSDN:

    http://msdn.microsoft.com/en-us/library/windows/desktop/bb762153(v=vs.85).aspx

    PHP 5.4 builtin webserver:

    http://php.net/manual/en/features.commandline.webserver.php

    That line will look something like this:

    ShellExecute(NULL, TEXT("open"), TEXT("C:\program files\YourApplication\php.exe"), "-S 127.0.0.1:1234", NULL, SW_HIDE);

    (you will have to close that webserver when your application is being closed)

  3. SQLite is a simple database and don't need to run any additional service, a php builtin server that is explained in step 2 is all that is required to connect to sqlite database. In php.ini you need to load PDO extension + pdo_sqlite.

Put your exe (YourProgram.exe) + php binaries (php.exe + dlls + extensions + php.ini) + your .php source files => put it all into one directory, create some installer using for example NSIS:

http://nsis.sourceforge.net/Main_Page

and you're ready to rock.

GooD LucK.

PS. Regarding the PHP-GTK, have a look at this interesting project I've came across recently, WinBinder: http://winbinder.org/index.php

SUMMARY

You create a c++ wrapper only once and it's easy, then you can run your php scripts as a native windows application - a IE webbrowser control is created inside your application's window and it navigates to 127.0.0.1:1234, which is the output of your php scripts. It looks like a regular program, but it's really an embedded browser inside your application.

There is no installation of apache, php or mysql required - it's like running native windows application. A small c++ wrapper that can be easily created with simple wizards and that can run your PHP scripts later on clients machines, with no hassle, with a feeling of a normal desktop application:)

There is no need to install anything, as it uses PHP 5.4 which comes with a builtin web-server, it can be started easily with 1 line using c++ call to ShellExecute(). For database you can use SQLite which does not require running any service, php alone is sufficient.

Hope it is clear right now.

6
  • where from c++ jumped in ? I hope where u used c++ app it can be replaced with ` PHP app ` !
    – HalfWebDev
    Feb 6, 2012 at 20:16
  • @kushal: read it again more carefully, you create a c++ wrapper only once and it's easy, then you can run your php scripts as a native windows application - a IE webbrowser control is created inside your application's window and it navigates to 127.0.0.1:1234, which is the output of your php scripts. There is no installation of apache, php or mysql required - it's like running native windows application. A small c++ wrapper that can be easily created with simple wizards and that can run your PHP scripts later, with no hassle:) Feb 7, 2012 at 4:54
  • @kushal I've edited my answer and added a short summary, hope it clears the things now. And yes, you can call it a "PHP app"! A guy with c++ experience could help you create this wrapper for running your php scripts on clients machines within 30 minutes (but I think you can create it even by yourself, it's easy) - and you can use this skeletion later for many of your PHP apps. Feb 7, 2012 at 5:07
  • okay ,i will try . But will the interactivity ,speed and performance of a general app developed with this style of coding you mentioned be comaparable with typical standalone apps (the one with java or any such desktop programming language) ?
    – HalfWebDev
    Feb 12, 2012 at 7:29
  • 1
    @kushal, good to hear from you as for the last few days I've been working to make this idea "live", I already have working code and am adding many new features, there are still some issues as I want it to work "professionally" so I put the requirements high to myself. I've created a project at google code and have already created some documentation, have a look: code.google.com/p/phpdesktop . Regarding your question about interactivity and speed: Yes. For interactivity use XMLHttpRequest + JQuery, PHP itself is fast, you just need to know what you're doing. Feb 12, 2012 at 14:54
13

Why screw around trying to hack something together with technologies that werent designed for desktop app development, when you can use an actual desktop development tool to create an application with far less hassle?

Whatever you think you'd be saving by not learning a new language, you'd be wasting by trying to fit a square peg into a round hole. Use the right tool for the job.

Download something like Visual Studio Express for either C# or VB.Net, and try that out. Or Delphi, if you have a little budget to work with. You say you know PHP & MySQL. Well, SQL is SQL, so thats not an issue regardless of the language you choose. C# syntax shouldnt be too different from what you are used to looking at in PHP. But VB.Net shouldnt be too hard to approach, either. Delphi makes nice self-contained executables, making distribution much easier. Those are just a few options. There's also C++. Python, Java....

3
  • 5
    really don't know why this isn't the highest voted answer
    – Ryathal
    Feb 6, 2012 at 15:29
  • 1
    I am sorry but this isn't an answer. Many good technologies can be used for new purpose. Feb 7, 2012 at 12:20
  • 1
    Can and should are two very different things. There has to be some practical advantage to doing so, especially when you'd have to jump through hoops and introduce unnecessary complications (perhaps installing a web server process) to get it working. Feb 7, 2012 at 19:11
8

A web application intended to be used by one person can be hosted locally, since a personal computer can act as a server, hosting:

  • A web server.

    IIS is very easy to setup on any Windows machine and you don't need to download anything; Apache must be downloaded, but is very easy to setup too.

  • PHP.

    Once you have Apache/IIS, downloading and installing PHP is not very hard.

  • An SQL database.

    Most databases are ordinary products which can be installed on personal computers. The only problem would be the cost, but this doesn't concern you if you choose SQLite or a free version of Microsoft SQL Server or a free version of MySQL.

    SQLite would be probably the easiest. One less product to install is always better when you deal with a personal computer, and not a strictly controlled, protected and documented server environment.

A web application can also be used locally. Instead of entering an URI of a remote server, like http://example.com/, you'll use http://localhost/. While some browsers will refuse to run JavaScript of an HTML file you open from disk (file://.../Desktop/Example.htm), this is not a problem with localhost URIs.

Now, how the web application will be used? You said:

I have to develop an app for a gas agency where a database will store consumer numbers, names, addresses, and date delivered for a town

So if I understand well, you'll have several employees of the agency using the same application, right? In this case, you can't just install your web application on personal computers. They must share the same database, which requires to host it on a machine which will be accessed from others, i.e. a server. From that point, you have several approaches:

  • Host an SQLite file on a shared drive (it may even be a NAS, not a real server) and access it from several PCs. This approach is fundamentally bad.

    Since you're actually accessing the file itself, directly, if several users will perform an action at the same time, bad things will happen: the file will be locked by one user, or maybe some user will overwrite the changes made by another, etc. Don't do it.

  • Host an SQL database on a server, i.e. a simple PC of the agency that they will call a server, and everything else on PCs. Technically, you can do it. For example in server environments, it's not unusual to host the database and the application itself on different machines, mostly for performance reasons (some servers would be optimized for data manipulation, others - for computation).

    While particularly relevant in server environment, this approach must be avoided when possible in a context like yours, for security reasons. By providing a direct access to your database from any machine of the agency, you reduce the safety of your data. You may configure the security properly to protect the data from a malicious user, but you'll spend a few months doing it, and with some SQL products, it's not even possible.

  • Host everything on a server (i.e, again, a simple PC of the agency). This is probably the most viable solution. You'll have to access the web application by typing something like http://192.168.1.13/, which is ugly, or the name of the machine, which is, in most companies, even uglier. But still:

    1. The data of the agency is protected from malicious employees,

    2. When fixing a bug, you have to push the update to one machine only, not to PCs. The same applies to PHP itself. Would you rather update to PHP 5.3.11, once it's released, on one server, or you prefer doing it on PCs?

    3. Your source code is visible only by people who can access the server. You don't want any employee being able to read your PHP source code.

    4. There is only one version of your code. If you host your app on every PC, what will happen if one is actually broken while you push the update? Or what happens if an employee decided to modify the source code of your application?

    5. There is only one configuration to take in account, the server's one. PHP abstracts quite well the underlying hardware and configuration, but still. What if you need to store a temporary file, and you decide to write it to C:\Windows\Temp, and later you discover that on a precise PC, this part of your code crashes, because there is no C: on this PC?

7
  • You have put quite an effort to answer but sadly this is not what i am looking for . App needs to run on a single PC( its a small agency) so what i was expecting as a solution is to not to use xampp environment kind of stuff or i can say i do not want to use a db server (which is obvious as the app will be on one PC) . For this only. i mentioned "local storage" above . I did made a comment below regarding one PC thing but i am sorry for not updating it above .anyways i am updating the question above as it is creating a confusion. Still will be giving +1 to your effort:)
    – HalfWebDev
    Feb 5, 2012 at 19:29
  • 3
    I'm confused, reading your edit. You say "App will be running on a single PC": But then, you add: "Also if in future this app needs to be on more than one PC , i want my database and app to be portable too.": either you want it to be used from a single machine, or you want it to be portable with the ability to be used from several machines. In the first case, only the first part of my answer (before "Now, how the web application will be used?") applies. In the second case, the whole answer is still valid. Feb 5, 2012 at 20:23
  • the question is better edited now . The thing is ,i want a standalone app not involving web server and apparently not a web browser for for its access.
    – HalfWebDev
    Feb 6, 2012 at 15:53
  • @kushal: this is very different from your original question. I suggest that you post a separate question, asking if and how is it possible to run a web app without a web server or a browser, which is a quite strange request by the way. While PHP doesn't need a web server to run (php.net/manual/en/features.commandline.usage.php), choosing HTML and CSS for a non-web app is awkward. What about learning a language and paradigms already used for desktop applications? Feb 6, 2012 at 17:43
  • I understand you but the use of word DESKTOP in title says it all . The other hint could have been my edit of PHP-GTK . anyways this is what i intend my app to be -a desktop one . And about learning other language -man,this is exactly what i was scared of and the question came after out of this scareness only :(
    – HalfWebDev
    Feb 6, 2012 at 18:18
1

MySQL is definetly a reasonable choice for your case, I don't think it's a problem to install on customer side.

If you prefer a 'no installation' database, you can go for SQLite (which works with PHP)

1
  • for an app to be installed on a single computer ,it doesn't seem appropriate to install mysql and go for any such db server . these are better suited for multi users where security and privileges is an issue . I am looking along the lines of desktop scenario where storage is local (without a db server).
    – HalfWebDev
    Feb 5, 2012 at 11:55
1

I have been after the same thing, but for different purposes. My search lead me to Titanium

Its description from its website:

Titanium makes cross-platform native application development easy. A free and open source application development platform, Titanium lets you create native mobile, tablet and desktop application experiences using existing web skills like Javascript, HTML, CSS, Python, Ruby, and PHP

Alternatively you could try Server2Go. Basically it is a standalone WAMP server that you can put on a CD/USB disk etc. The problem with that would be the MySQL db would be read only if the server is to be on a CD. But then you can always use SQLLite db stored in the local disk or get around it differently.

I'm thinking Titanium will solve your problem... I should add that I haven't used it enough to know how good it is but there usually are positive reviews about it.

1
  • Hardly anyone has used it ,its not only you .Though Mobile development is a different scene with titanium and more popular than the desktop one .
    – HalfWebDev
    Feb 7, 2012 at 13:52
0

If your database is not online (I mean you database is not updated), you can use JavaScript, HTML and CSS to make your offline app (jQuery is a library of JavaScript). If your database is updated, you can make a website to display it to your clients. And you can ask your clients to add bookmark to your website to update info, or you can make Chrome apps (if your clients use Chrome as web browser) for you clients install directly on their Chrome web browser.

0

Check out CouchDB?

It is a simple, web oriented, JSON based NoSQL database.

You just need to install a single application and you have a NoSQL database with a web interface called Futon. You can easily create db-connected, lightweight web applications with html + javascript. CouchDB documents are available from web browser, and your program code (HTML + JavaScript + ...) can be like that too. And you don't need to install and configure PHP, MySQL, etc.

2
  • "CouchDB documents are available from web browser, and your program code (HTML + JavaScript + ...) can be like that too. " Sorry , i din't get you here ?
    – HalfWebDev
    Feb 6, 2012 at 18:42
  • I am sorry. My english is not very well. I mean CouchDB is available from webbrowser (default on port 5984) and You can store and serve your web page (HTML, javascript, etc.) from database. There is GUI tool embedded into CouchDB and it works like that.
    – marcinpz
    Feb 7, 2012 at 7:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.