Jump to content

Question RE GTK


onlyican

Recommended Posts

MODS: Move if ya must, but GTK is PHP at the end of the day

Anyway
Guys, Girls,
I am starting on PHP GTK
and as it stands at the moment, as far as I know, there are no decent compilers to create the files into a .exe, (not for GTK2)
So the only way of running the application, is to have the GTK stuff installed on the users machine, (.NET requere .NET Framework, so still the same sorta ting)
AND
Sendin them the php files, which with a simple text editor, they can view the code

SO
I was thinking about storing the .php files on a Web Server, and the user installs the GTK stuff, and has the phpw file
Which they run, and uses the file from the website

OK
if your lost already, then dont bother reading on, cos I am just getting started

I uploaded the files to my WebServer
and I changed the phpw file to
include('http://www.example.com/gtk/main.php');
(Instead of the usual
include(dirname(__FILE__) .'/test.php');
)

I am running Crimson Editor, and it comes up with the php cmd promt, and briefly shows an error messages, then closes
I managed to screen grab this message, so I can read it (Took ages, but)

It was saying about a Parse Error on line 6
Line 6 Reads
function login(GtkWindow $wnd, GtkEntry $txtUsername, GtkEntry $txtPassword){
Which
Before you guys who dont know about GTK, jump
Yes, is an error in PHP Web
but
its normal in PHP GTK
I can run the same file from my machine no problems

So
If your still with me, you deserve a pat on the back

I was thinking
This error is cos the web server has not got php GTK set up

SO
Does this mean, if the web server has php gtk installed, then the user does not need to install PHP GTK

if true
Then how would the user run the phpw file

if False (which I tink)
Then how come when I run the file, its looking on the servers php settings, not my machine

Any ways round this at all
God, I need a smoke now, after typing all this

Anything is appriciated (except the comments like "HUH")

Link to comment
Share on other sites

[quote]Does this mean, if the web server has php gtk installed, then the user does not need to install PHP GTK[/quote]

No... the client will still need php-gtk installed. What you are best off trying to do (if you really want to try and hide your code) is let your processing be done on the server with plain php. This would be the bussiness layer of your application. You then need to have all your php-gtk (gui stuff) on the client. This allows you to hide most of your logic, while your application remians semi-efficient.

Ideally, your best option would be to have the entire application run on the client and have a good license in place.

Another and IMO the best option (though it may involve learning a new language) would be to switch your entire application to python. There are plenty of py to exe compilers around and python's gtk implimentation is much stronger then php's. I used to write php-gtk applications for a living before moving all my applications to python. Im sorry, but I just don't believe php is very strong in this area. Its gtk implimentation feels flaky at best, bordering on buggy. I just always get the feeling its about to crash. Python is rock solid in this area and really, for desktop applications python has a much larger / more versatile system api.
Link to comment
Share on other sites

[quote]
SO
I was thinking about storing the .php files on a Web Server, and the user installs the GTK stuff, and has the phpw file
Which they run, and uses the file from the website
[/quote]

Let me try to answer your question.

Just remember that php-gtk is used to display GUI on whatever machine it is running on.

Even if you're able to fire up php-gtk on the remote server (e.g. with your example of include('http://www.example.com/gtk/main.php')), you won't be able to see anything at the client side. The php-gtk is running on the server, and the output does not "propagate" via network to be displayed on the remote client.

You can, however, include some files from a remote server.
For example, try this example: (Note: you need to have php-gtk2 installed on your machine.)
<?php
include "http://www.kksou.com/php-gtk2/remote/hello_world.phps";
hello_world();
?>

You should be able to see this:
[img]http://www.kksou.com/php-gtk2/gif/0028.gif[/img]

You can see a full explanation here: [url=http://www.kksou.com/php-gtk2/articles/distribute-your-PHP---GTK-applications---Method-1.php]http://www.kksou.com/php-gtk2/articles/distribute-your-PHP---GTK-applications---Method-1.php[/url]

This method does not "protect" your code at all. Just type the url: http://www.kksou.com/php-gtk2/remote/hello_world.phps into your browser, and you will see the entire content of the file displayed. "Protection" is not the main purpose for this. We use this more for ease of maintenance and updating of php-gtk application over large number of sites.

thorpe mentioned about hiding the bussiness layer of your application with a server in his reply to you. You can find an example here: [url=http://www.kksou.com/php-gtk2/articles/hide-sensitive-business-rules-of-your-application-securely.php]http://www.kksou.com/php-gtk2/articles/hide-sensitive-business-rules-of-your-application-securely.php[/url]

So, in short,
1) Yes, you have to install php-gtk2 on all machines that wants to run your php-gtk2 scripts. (Unless, of course, some php-gtk2 compilers come out later that allows you to compile everything into a standalone .exe)

2) The server can run php-gtk2, but you won't be able to see it from your client side. We use the server for other purpose, as described above.

3) If I understand correctly, your intention of putting your codes on the server is to try to hide your script away from the user. As mentioned above, because you're using an "include" statement, the user can easily grab a copy of that file.

As for the comments from thorpe with regards to python's gtk, I agree it's a much more established platform than php-gtk2. We almost wanted to switch over to using python initially. However we finally decide to stay with php for 2 main reasons:

a) We do a lot of web programming. Sharing codes between our web application and php-gtk is so much easier. We could use the same library, just different front-ends.

b) Comparing Python with PHP is like comparing Microsoft Windows and Mac. In real life, sometimes the best just aren't the most popular. If you use OO a lot, you will know that PHP still lags behind Python. But the fact is that the PHP community is much larger than the Python base. This means there are more support available, including documentations, forums, codes, etc. For companies, it also means a large pool of PHP programmers for them to choose from.



Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.