Equivalent of COM objects in PHP (avoiding huge includes)

This is a discussion on Equivalent of COM objects in PHP (avoiding huge includes) within the PHP Language forums, part of the PHP Programming Forums category; Hi, Wonder if anyone can help ..... is there anything at all similar in PHP to COM objects? i.e. where ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-15-2003
michela rossi
 
Posts: n/a
Default Equivalent of COM objects in PHP (avoiding huge includes)

Hi,

Wonder if anyone can help ..... is there anything at all similar in
PHP to COM objects? i.e. where one can compile functionality into a
server side component? I am talking Unix here not Windows.

If there isn't - how do people cope when building very large PHP
projects without ending up with huge includes on every page?

If anyone can point me to a good article on approaches to dealing with
this I'd be most interested.

Many thanks,
Michela.
Reply With Quote
  #2 (permalink)  
Old 10-15-2003
Ian P. Christian
 
Posts: n/a
Default Re: Equivalent of COM objects in PHP (avoiding huge includes)

michela rossi wrote:

> If there isn't - how do people cope when building very large PHP
> projects without ending up with huge includes on every page?


I personally use Classes to group my code. There are lots of useful classes
in PEAR that help prevent reinventing the wheel.
You don't need to create an instance of a class to use it's functions, so
they can be used for logical grouping of functions.

I also tend to have one file that will then include all files that will be
used across a project, so only one line is needed at the top of all pages
(with a few exceptions).

Hope this helps,

Ian P. Christian
Reply With Quote
  #3 (permalink)  
Old 10-16-2003
Nikolai Chuvakhin
 
Posts: n/a
Default Re: Equivalent of COM objects in PHP (avoiding huge includes)

michela_rossi66@hotmail.com (michela rossi) wrote
in message news:<1ed550fd.0310150850.50a8eed7@posting.google. com>...
>
> Wonder if anyone can help ..... is there anything at all similar in
> PHP to COM objects? i.e. where one can compile functionality into a
> server side component? I am talking Unix here not Windows.


Yes. You can develop PHP extensions, which are basically function
libraries written in C. Then you can compile your extension, configure
PHP to work with it, and, voila, you can use your_brand_new_function()
just as you normally use fopen() or array().

> If there isn't - how do people cope when building very large PHP
> projects without ending up with huge includes on every page?


By compartmentalizing and documenting. If you look at the source code
for any large PHP project, you will see includes and requires in bunches.
Last I checked, when you log into phpMyAdmin, the frameset contains two
requires, the right frame, four...

Cheers,
NC
Reply With Quote
  #4 (permalink)  
Old 10-16-2003
michela rossi
 
Posts: n/a
Default Re: Equivalent of COM objects in PHP (avoiding huge includes)

> Yes. You can develop PHP extensions, which are basically function
> libraries written in C. Then you can compile your extension, configure
> PHP to work with it, and, voila, you can use your_brand_new_function()
> just as you normally use fopen() or array().
>


**** Aha. Thanks very much. What kind of configuration of PHP do you
have to do? I'm just thinking it'd be good to be able to use them on
shared webspace, i.e. one where one doesn't have SSH access - I
suppose it isn't as simple as just putting the compiled extensions in
a folder, presumably you have to alter php.ini or even recompile PHP?

>
> By compartmentalizing and documenting. If you look at the source code
> for any large PHP project, you will see includes and requires in bunches.
> Last I checked, when you log into phpMyAdmin, the frameset contains two
> requires, the right frame, four...
>


**** Any hints as to what projects are good ones to look at re: the
compartmentalizing and documenting includes? I've looked at
http://www.drupal.org/ in the passed.

**** Many, many thanks for your help.
**** Cheers Michela.
Reply With Quote
  #5 (permalink)  
Old 10-17-2003
Nikolai Chuvakhin
 
Posts: n/a
Default Re: Equivalent of COM objects in PHP (avoiding huge includes)

michela_rossi66@hotmail.com (michela rossi) wrote in message
news:<1ed550fd.0310160022.bb11a9e@posting.google.c om>...
>

NC> You can develop PHP extensions, which are basically function
NC> libraries written in C. Then you can compile your extension,
NC> configure PHP to work with it, and, voila, you can use
NC> your_brand_new_function() just as you normally use fopen()
NC> or array().
>
> What kind of configuration of PHP do you have to do? I'm just
> thinking it'd be good to be able to use them on shared webspace


Not likely. You need quite a bit of control over your PHP installation
in order to be able to deploy custom extentions.

> I suppose it isn't as simple as just putting the compiled extensions
> in a folder, presumably you have to alter php.ini or even recompile PHP?


Depends. Sometimes, you can get around the drastic measures by
dynamically loading a library:

http://php.net/dl

But even then, that library needs to be in the directory defined by
the extension_dir directive in php.ini, which is usually a restricted-
access directory.

NC> By compartmentalizing and documenting. If you look at the source
NC> code for any large PHP project, you will see includes and requires
NC> in bunches.
>
> Any hints as to what projects are good ones to look at re: the
> compartmentalizing and documenting includes?


Unfortunately, good documentation is a rather unusual occurrence
in the open-source movement...

Cheers,
NC
Reply With Quote
  #6 (permalink)  
Old 10-17-2003
Jochen Daum
 
Posts: n/a
Default Re: Equivalent of COM objects in PHP (avoiding huge includes)

Hi michela!

>
>**** Any hints as to what projects are good ones to look at re: the
>compartmentalizing and documenting includes? I've looked at
>http://www.drupal.org/ in the passed.


www.phpdoc.org
>
>**** Many, many thanks for your help.
>**** Cheers Michela.


--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Reply With Quote
  #7 (permalink)  
Old 10-17-2003
André Nęss
 
Posts: n/a
Default Re: Equivalent of COM objects in PHP (avoiding huge includes)

michela rossi:

> Hi,
>
> Wonder if anyone can help ..... is there anything at all similar in
> PHP to COM objects? i.e. where one can compile functionality into a
> server side component? I am talking Unix here not Windows.
>
> If there isn't - how do people cope when building very large PHP
> projects without ending up with huge includes on every page?


Well the first thing you should ask yourself is if huge includes really are
a problem. If they are you can get improved performance by using something
like the Zend Cache and the Zend Optimizer.

André Nęss
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:35 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0