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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
> 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. |
|
|||
|
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 |
|
|||
|
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/ |
|
|||
|
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 |