LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-24-2008, 05:58 AM   #1
DeNayGo
Member
 
Registered: Jun 2005
Location: Aachen, Germany
Distribution: Debian
Posts: 74

Rep: Reputation: 16
PHP-style library for C/C++?


I've been programming web applications in PHP for a very long time now, but whenever I start a new project I'm wondering if it wouldn't be better and easier to use C++. I guess that some people here will agree with me, and many probably won't, but let's just ignore that

So the only reason I'm still using PHP is time. I have to put up with the language but I'm rewarded with a library that does very many things I'd have to do myself in C++. It's not just the HTTP-related stuff like cookies and headers, file uploads and all that, it's also the other parts of the library, such as file_get_contents() and the like.

I think there's really nothing wrong with having a way to request a local or HTTP file in one single line, but in C++ that just does not seem to be possible, not with the libraries I've seen.

So I'm thinking about finally taking this step and switching to C++, and I'm even ready to write my own little library that can simplify many things for me.
But before I go ahead with this I wanna make sure there really isn't anything useful out there I've overlooked.

So does anyone know about a library like what I've described?

(And, yes, I know about Java Servlets and all that but that just isn't for me )

TIA
 
Old 03-24-2008, 06:03 AM   #2
exscape
Member
 
Registered: Aug 2007
Location: Sweden
Distribution: OS X, Gentoo, FreeBSD
Posts: 82

Rep: Reputation: 15
Hmm, are you looking to use C/C++ for the same purpose as PHP, i.e. creating web sites, etc? If so, I wouldn't look at just any programming language, but either a web-specialized one (like PHP), or something with a web framework (like Python + Django, Python + Turbogears, Ruby + Rails, Perl + Catalyst). C++ just isn't very optimal, at all, for that purpose.
 
Old 03-24-2008, 06:17 AM   #3
DeNayGo
Member
 
Registered: Jun 2005
Location: Aachen, Germany
Distribution: Debian
Posts: 74

Original Poster
Rep: Reputation: 16
I know, that's my point. I want to make it optimal

I realize that C++ makes it more complicated in most cases, but I actually want that. I want static typing and all that cause only then can I really control and predict the application's behavior in all situations. And I also like multiple inheritance and stuff like that.

For small scripts with simple purposes I would still use PHP (anything else wouldn't make any sense cause most of what I write has to be able to run on any webserver out there), but what I'm working on mostly is big database backends or CMSs that include database backends. For those things I want all the power C++ can give me, PHP and other scripting languages just aren't nearly enough for that.
Anyway even in those projects I have to do some thins that are not database- but web-related, and for that I need functionality similar to that of PHP.
 
Old 03-24-2008, 12:31 PM   #4
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
Why not use php as a frontend to a C or C++ library? You can compile shared objects for php in C or C++ and use them from your php scripts. Otherwise, compile your C or C++ program as a server to which your php script may make a socket or other IPC connection.
 
Old 03-24-2008, 01:21 PM   #5
DeNayGo
Member
 
Registered: Jun 2005
Location: Aachen, Germany
Distribution: Debian
Posts: 74

Original Poster
Rep: Reputation: 16
That with the modules sounds interesting Do you have any more information on that? Is that "officially supported" by PHP or does it involve some hacking?

The problem is that some of my projects have to run on servers that don't belong to me. For my own server I would probably write a database deamon indepent of HTTP, but I guess the big hosting companies my customers like to use would not allow that So I have to use something that's either supported by most servers or that can go in the cgi-bin folder...
 
Old 03-24-2008, 06:48 PM   #6
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
It is “officially supported” in the sense that the majority of php is in extensions (some of which are third-party and some of which come with php). Here is a tutorial.

Some hosting providers allow you to use your own compiled extensions (if you upload them to the libexec directory), but you’ll have to check whether or not yours does as well.
 
Old 03-24-2008, 07:42 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,965
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
Quote:
Originally Posted by DeNayGo View Post
I know, that's my point. I want to make it optimal :)

I realize that C++ makes it more complicated in most cases, but I actually want that. I want static typing and all that cause only then can I really control and predict the application's behavior in all situations. And I also like multiple inheritance and stuff like that.

For small scripts with simple purposes I would still use PHP (anything else wouldn't make any sense cause most of what I write has to be able to run on any webserver out there), but what I'm working on mostly is big database backends or CMSs that include database backends. For those things I want all the power C++ can give me, PHP and other scripting languages just aren't nearly enough for that.
Anyway even in those projects I have to do some thins that are not database- but web-related, and for that I need functionality similar to that of PHP.
Did you come across witty in your searches?



Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RH 3 - Update PHP and GD Library SharkBait Red Hat 1 09-12-2006 06:10 AM
problem about GD library link to PHP arcow Linux - Software 4 02-03-2006 02:09 AM
PHP & GD library problem mmilan Linux - Software 2 11-15-2005 06:00 AM
VIM-style wrapping to OpenOffice style schmmd Linux - Software 1 12-21-2004 06:50 PM
Re-compiling PHP with GD library ubers0ldat Linux - Software 1 08-20-2003 02:59 PM


All times are GMT -5. The time now is 03:57 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration