Rendering web content in offline/desktop applications - php

For a while now, I've been thinking about the question of user interface, with regard to ease of implementation and cross-platform compatibility. I'm primarily interested in developing desktop applications, for things that don't have a server-side storage model, or situations where internet connectivity is intermittent, etc. However, I've started doing some work on my employer's website, and found in that time that web site interfaces are very easy to develop, especially in comparison with the cross-platform UI tools I've used in the past.
With that in mind, I want to know: what are the tools/libraries available that can be integrated into a desktop application to render web content? Could be HTML, PHP, JavaScript, with/without CSS, etc. How easy/difficult are they to use?

You might actually want to check out Microsoft's Windows Presentation Foundation. It takes a lot from how the web works and applies it to desktop application development. It's not exactly HTML/CSS/PHP/JS, but it's not far off, either. It does have a bit of a learning curve, but the markup is XML based, so it's largely just a matter of learning its quirks, and of course, the .Net languages and framework (though, theoretically, you could use PHP on the .Net framework).
You might also be interested in Appcelerator Titanium, which allows you to use HTML/CSS/JS to build desktop applications. I don't know what it's desktop development is like, but I've used it for iPhone development, and it has promise.
If you want to play around with plugin/extension writing, the latest Gnome desktop environment (Gnome 3 - http://www.gnome.org/) actually runs completely off of HTML/CSS/JS and could use people to help build their extension library. It is, literally, writing desktop apps! :) (You would, of course, have to run Linux to play with it, but Fedora 15 uses Gnome 3 by default, and Linux in general comes with a number of powerful text editors, and the community has done a great job writing tutorials and documentations for getting started.)

If I understand the question right, to my knowledge there is nothing truly cross platform for doing this, you would always have to write a different version for each target platform.
Most windows apps that render web content sub the task out to IE, but I don't know how *nix app would handle this.
To use PHP to do anything on the local machine, it would have to be installed on the local machine. You can supposedly build full Windows GUIs in PHP with Winbinder although I have never messed around with it myself.
For windows-only apps, you might find HTA interesting - these are (sort of) self-contained HTML/Jscript apps and you can use links and Jscript to fetch content from remote servers.
I think your best bet would be Java though - the Java mantra is 'Write once, run anywhere' and Java GUIs are extremely portable. I'm sure I remember coming across something whereby you could use HTML to build bits of a Swing GUI as well...

What about Adobe Air? I'm not caught up on its capabilities, but I run Pandora Desktop on my Mac, which goes through Adobe Air - My impression was that it fulfills what the OP is asking.

You should have a look at Adobe AIR:
Adobe AIR with PHP/MySql or SQLite
http://www.vtc.com/products/Adobe-AIR-PHP-Development-Tutorials.htm
Never used it though so I can't really give you details but maybe somebody who has can... hope this helps

Related

Web programming Python [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm a amateur developer with a little experience in PHP.
I recently learnt Python, I've to admit that it is awesome as a programming language and its great libraries, but using that for web development seems to be a big pain in the ass. As far as what i read, I've to use CGI, mod_wsgi, etc. to deploy (http://docs.python.org/howto/webservers.html), Restart the server to see the changes (http://stackoverflow.com/questions/581038/python-web-programming)
My question is, Python being used so widely for web development, Why cant it be as simple as PHP?
ie i would love to write index.py:
print """
<html>
<head>
<title>Hello world</title>
</head>
<body>
Hello world
</body>
</html>"""
First to your question on why Python isn't as easy for web development as PHP: It hasn't been designed for it. PHP has had a lot of work towards making it a good language to write HTML pages in, including mod_php for apache. Python, while it is a very capable web language, it is also capable of far more than PHP. For example, the majority of Dropbox's software, both the desktop client and the server side code is Python. I use Python in my day job and have used it to integrate legacy C code into new Python code via Cython.
Moving on. There are a number of Python frameworks out there that can make your web development experience far less complicated. 2 of note that are widely used professionally and by hobbyists are Django and Pyramid (formerly Pylons). As a new user I'd recommend you start with Django, it's a great way to get started and can be used for large and complex sites (and more) as your experience grows.
You will find that Django and Pyramid include "development servers". These are web servers written in Python that are packaged with the frameworks to enable faster development. Using these development servers you can get up and running very quickly.
There are also pure Python web servers that are infact incredibly fast, robust and very production ready. To deploy a Pyramid application on Gunicorn, a very good Python server, only takes a couple of extra lines in your Pyramid configuration. Typically you would reverse proxy to these pure Python servers via Apache or Nginx.
If you want to go the Apache server route, you just need mod_wsgi. Serving a Python site with mod_python or as a CGI is a somewhat outdated way of doing it. WSGI defines a standard for Python to handle web requests so mod_wsgi enables apache to pass requests to your Python application in the expected format.
When it comes to deploying Python to a hosting provider, you have to look a little further than you would for PHP hosting, but there is a good list maintained on the official Python wiki. The 4 links at the bottom provided different lists to meet your requirements.
[If] Python being used so widely for web development, Why cant it be as simple as PHP? ie i would love to write index.py...
Python can be as simple as PHP, as per your example. The simplest way to make the above work is to use CGI (and call your file index.cgi rather than index.py, then your script will work just fine. Though you should really specify the content type first, like this:
print 'Content-type: text/html'
This would apply in PHP as much as Python. Python's CGI module will get you up and running very quickly.
As far as what i read, I've to use CGI, mod_wsgi, etc. to deploy
You would normally choose one or the other, and realistically you would most likely choose a framework which is based on the more modern WSGI and not worry about the low-level stuff. But if you don't want to, you don't need to bother with these low-level interfaces.
Restart the server to see the changes
Probably not. Having to restart the server is a limitation of the framework and deployment configuration, and is typically not required. If you use mod_python this may apply, but generally not (many frameworks support auto-reloading, for example).
Python has a great wealth of resources for web development. There are bare-bones systems (eg. CGI, mod_wsgi), lightweight systems (eg. CherryPy) and entire frameworks (eg. Zope). You can choose one that best suits your needs.
Being able to create a simple file and produce some output might help get something going quickly, but it is not really a sign of a rich, mature, featureful framework. Sure, you can start displaying something straight away, but what then? All of a sudden you will need to either import or write all the same sorts of functionality that web frameworks provide. For a non-trivial web app, you need non-trivial framework.
For example, something like Django will give you a persistence framework, auto-generated admin interface, a tempting language, URL dispatch system, and much more. You can focus on your app logic, and not worry about the lower level details. Django is a good place to start, as it has great documentation and the tutorial will get you going very quickly.
As others have said, google "python web framework". There are quite a few, they are all quite different. To get you started the fastest (hours), I'd look at bottle.py.
Python being used so widely for web development, Why cant it be as simple as PHP?
Because Hello World don't scale. Because Python ain't PHP. From wikipedia[1] [2]:
Python is a general-purpose, high-level programming language
PHP is a general-purpose server-side scripting language originally designed for Web development
Python is great, python is DRY friendly. Unfortunately, when it comes to web developement, DRY isn't enough. If you actually want to get things done (efficiently): don't reinvent the wheel. That was pretty well summarized here:
What seems the biggest shame to me is that everyone is currently rebuilding this stuff over and over again and rationalizing it as some sort of secret sauce competitive advantage when it’s really infrastructure – stuff that really should be standardized so you can actually get around to doing the new and interesting stuff.
So, use the right tool for the right job, if you go the python way:
use python and
use a web framework, Django is great (or another one)
reuse packages, browse them at django-packages
maybe use a "meta-framework" like Pinax to get started
use Twitter Bootstrap as an UI framework
use a PaaS like Heroku to deploy (or another one)
Yeah it's more complicated than a hello world but remember there ain't no such thing as a free lunch. You're an amateur developer, you're not a professional coder and a sysadmin and a database admin and a designer and a system architect, etc. Don't be too shy to stand on the shoulders of giants because now, it's free. Please, don't build nothing less than a modern web app.
Also, PHP isn't anymore popular as it was [1][2], cf. PHP's fractal bad design, PHP hammer, etc.
PHP was solely meant for web application development, to be more precise for building Personal Home Page(s) (thats where P, H and P came). Python on the other hand is a general purpose programming language. It was meant for a whole lot of things (and had to include all sorts of batteries for all sorts of tasks). So, please do not expect Python to behave the same way PHP does.
Stand alone python scripts will require quite a bit of efforts to run. I would suggest to pickup a web framework. You might want to learn django (https://www.djangoproject.com/) to begin with. You might also want to give Google App Engine a try. Besides heroku, dotcloud, nuagehq and other cloud hosts make python (and django) deployment very simple and easy.
Hope you'd enjoy developing web apps with Python! :)

What non-OO language can a web dev use to create a one-off desktop app?

I'm looking to develop a Win32 desktop app - a one off, for a personal need. A GUI is not scrictly needed, though would be a bonus.
What is needed:
The ability to monitor the window title of a specific window.
The ability to run DOS commands when this window title changes.
I hope my programming ability is up to this - I feel I'm pretty good with PHP, but I'm not ready to spend time learning OO for this one-off project.
What non OO (or at least not mandatorily OO) languages are there for desktop apps that might be suitable for a beginner on a task like?
Any other, more hacky approaches are welcome too - batch scripts etc.
Many thanks for any advice,
Jack
Whether or not the language supports OO doesn't really matter for your purposes. After all, PHP supports objects and you seem to do just fine with it.
Personally, i'd recommend Java or C# to get started with. The communities for these two languages are huge and there are plenty of tutorials online to help you get started.
It's extremely easy to get starting writing C# with Visual Studio Express. And a good hello world tutorial.
Also, if you stick with C# you can take advantage of WMI which will allow you to do everything you need for this project (and much much more).
Lastly, most windows machines will be able to run your application without having to install anything extra and Visual Studio builds the .exe for you as part of the build process.
You can use PHP for desktop apps if you really want to. Just install the php CLI.
You can even do a gui for your desktop app in php: http://gtk.php.net/
EDIT: I'm not sure how easily you can call win32 api functions from PHP, however. There look to be a few articles about this online and a SO question: How to call winapi functions from PHP?
I would vote for Python using the included TkInter module for GUI. Dead simple to use.
Widgets aren't the prettiest looking, but development is rapid.
EDIT: I mistook "non-OO" in the question for "OO". Python is most definitely not "non-OO", but but is very well suited to doing what you asked.
You could write this in pretty much any mainstream language supported by Windows. C or C++ are obvious choices. C# and Visual Basic .NET are going to require the .NET Framework ... not a bad thing, but perhaps more than you want to tackle for a simple project. Come to think of it, you might be able to do this with JScript or VBScript, although I'm not clear on what API functions you have easy access to. And I have to believe that it's possible to do with PowerShell with just a little work.
Your options are wide open.
F#
It's an awesome piece of work, has access to the Framework class libraries, supports GUI development, really easy parallel programming, compiles to IL (same as C#) but has a really concise functional syntax.

Web technologies for an embedded server

I've recently started a new web development project for an embedded device and wanted to solicit some recommendations for technologies to use. The device will serve HTML pages which include AJAX code to retrieve data from a JSON server. We're tentatively using Cherokee as the web server, though we're not tied to it.
Currently, I'm considering the following technologies:
Write it all in PHP. I know it's big, slow, and bloated, but I've got about 10MB available for the web interface (a lot for an embedded system), and we won't be seeing a lot of traffic on any of these devices. It does need to seem responsive for the users, however (pages should load in less than a second).
FastCGI + a C program - We're using an in-memory database, so the C program could interact with the database directly through the API. This would have much better performance than PHP, but development time and reliability is a concern since C isn't very well-suited for web development.
Lua + Kepler - This seems like a nice middle ground between performance and development time. However, I've never worked with Lua, so I'm not really sure how to implement it in an embedded web project. I'm also uncertain as to how well it integrates with the Cherokee web server.
So any opinions or past experiences with the above stated technologies? Any others I should include in the list?
Thanks,
Alex
When I was in this area, I used Lua and a simple FastCGI runner (Luaetta [for I'm sure the latest source would be available if you asked the guy] , though I'm also sure that's not the only one, and there's Kepler of course), spawned by lighttpd.
It performed quite well on an embedded media player, and was used for remotely accessing content and controlling the device. Though I don't maintain it anymore, you can find more about it at http://matthewwild.co.uk/projects/wooble . If you think the source would help just poke me for it, it's currently only available via a package manager but I can fix that given the motivation.
Another (again Lua) project in this area is LuCI. These guys are dedicated to making a web interface for embedded devices (routers specifically), and have produced a nice framework with lots of supporting libraries geared towards that kind of system.
I wouldn't be concerned with not knowing Lua. If you know any language then you can pick up Lua in a day or two, the manual documents the whole language and is quite short.
How about looking at HipHop, Facebook's PHP compiler?
https://github.com/facebook/hiphop-php/wiki
That way you can write your code in PHP and effectively compile it to C++.
ASP.NET. Assuming that you wouldn't be interested in Embedded Windows Server 2008, you could still leverage ASP.NET by incorporating Mono into Cherokee. You could leverage Visual Studio as your RAD development environment and use things like ASP.NET MVC 2. A lot of third party user controls will also 'just work' with Mono (Telerik Announces Support for their ASP.NET controls on Mono!).

Old desktop programmer wants to create S+S project

I have an idea for a product that I want to be web-based. But because I live in a part of the world where the internet is not always available, there needs to be a client desktop component that is available for when the internet is down. Also, I have been a SQL programmer, a desktop application programmer using dBase, VB and Pascal, and I have created simple websites using HTML and website creation tools, such as Frontpage.
So from my research, I think I have the following options; PHP, Ruby on Rails, Python or .NET for the programming side. MySQL for the DB. And Apache, or possibly IIS, for the webserver.
I will probably start with a local ISP provider for the cloud servce. But then maybe move to something more "robust" and universal in the future, ie. Amazon, or Azure, or something along that line.
My question then is this. What would you recommend for something like this? I'm sure that I have not listed all of the possibilities, but the ones I have researched and thought of.
Thanks everyone,
Craig
If you want a 'desktop component' that is available for you to do development on whenever your internet is out, you could really choose any of those technologies. You can always have a local server (like apache) running on your machine, as well as a local sql database, though if your database contains a large amount of data you may need to scale it down.
Ruby on Rails may be the easiest for you to get started with, though, since it comes packaged with WEBrick (a ruby library that provides HTTP services), and SQLite, a lightweight SQL database management system. Ruby on Rails is configured by default to use these.
The languages you list are all serverside components. The big question is whether you can sensibly build a thick client - effectively you could develop a multi-tier application where the webserver sits on the client and uses a webservice as a datafeed if/when its available but the solution is not very portable.
You could build a purely ajax driven website in javascript then deploy it to the client as signed javascripts on the local filesystem (they need to be signed to get around the restriction that javscripts can only connect back to the server where they served from normally).
Another approach would be to use Google Gears - but that would be a single browser solution.
C.
If you wan't to run a version of the server on desktops, your best options would be Python, Rails, or Java servlets, all of which can be easily packaged into small self contained servers with no dependencies.
My recommendation for the desktop would be HTML 5 local storage. The standard hasn't been finalized, but there is experimental support in Google Chrome. If you can force your users to use a specific browser version, you should be OK, until it is finalized.
I would recommend looking at Django and Rails before any other framework. They have different design philosophies, so one of them might be better suited for your application. Another framework to consider is Grails, which is essentially a clone of Rails in the groovy language.

New Website Project Silverlight / Php

Very recently I have been given a facebook like project to develop for a client of mine.
Most of the time when i comes to web development I use php since the solution PHP, apache, MySql which are all freely availble solutions, I have been thinking about using Silverlight to develop the web application, and I would like to hear some pros and cons with develping a web application in silverlight.
what do you use to host the application? its costs and so on compared a LAMP solution.
Thanks,
Eric.
Having not a clue of the type of app you're building, I need to ask: why do you think you need Silverlight? The main problem with walled-garden solutions like Flash and Silverlight is that they do not play very well with the users model of their browser. Things like bookmarks and back button tend to do the wrong thing. You can't easily navigate away and come back to what you were doing. Jeff and Joel have ranted about this in their podcasts.
Nearly everything you can imagine needing Silverlight / Flash for these days can probably be handled by a javascript/jQuery UI kit / plugin of some sort ..
Silverlight especially still has a pretty low penetration rate even with MS holding it up for you to accept during updates.
I do think there are types of applications for which these technologies make sense. Especially if they are very heavily graphically or interactively intensive. I would look at Flex sooner than Silverlight in that case.
I'd say the decision starts off with who needs to access this application. If it's got to run on a wide range of browsers and platforms, you're safer sticking with HTML, CSS & JavaScript as the technologies. If you're happy with PHP as the server side technology, then stick with it. You'll find the learning curve for .NET applications pretty steep.
That said, for larger projects, the slightly better practises that .NET tends to push you towards helps. Some PHP projects start small and then need to scale exposing flaws in the original architecture. The same thing obviously can happen with .NET but less so IMHO as the programmers using it tend to have slightly more disiplined training. There are of course, exceptions to all rules.
The attraction of Silverlight though is big - the ability to develop client side code in familar .NET languages and not JavaScript is appealing. Personally, the whole HTML, CSS and JavaScript (with Ajax) set-up is offensive from an asthetic point of view :-)
Rob.
PS. It will be more expensive for the development environment and back-end compared to LAMP. Only you can decide whether the investment is worthwhile.
Creating a website in SilverLight is as bad of an idea as using Flash:
Users cant print
Users can't bookmark
Search engines can't index specific
"pages"
Silverlight exists for the reason of making apps that aren't possible with traditional HTML/JS and a Facebook like app is not one of them.
If facebook itself uses PHP, why not develop it in PHP?

Categories