Re: [PHP] Structure of PHP files

2009-07-23 Thread Robert Cummings



Paul M Foster wrote:

On Thu, Jul 23, 2009 at 09:34:37AM -0400, Robert Cummings wrote:




Not that I disagree with your methodology at this time, but you could
have just made that single big file, include all those little files and
still had a single load statement in each of your consumer source files.
With compile caches the burden of loading all that code at startup is
rather negligible :)


I've heard this before, and I don't understand why people say this. If
you have a 150k file you load before displaying a page, you've still
occupied the CPU with the task of loading a 150k file. What happens to
it afterward (compiling, compressing, caching, whatever) is another
issue. You've still loaded 150k of code. The question is whether you
actually need to load 150k of code from the start. If not, why waste the
resources?


150k is peanuts and having it already in memory means it doesn't have to 
be loaded later. With a compile cache it's quite likely that over time 
you'll have the 150k loaded into memory anyways. It's just going to take 
longer for it to be loaded since the compile cache has to "encounter" it 
first. Once "encountered" it's still occupying the same memory. 
Additionally, the operating system does an excellent job of swapping 
memory not being accessed regularly (if it needs memory).


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Structure of PHP files

2009-07-23 Thread Paul M Foster
On Thu, Jul 23, 2009 at 09:34:37AM -0400, Robert Cummings wrote:



> Not that I disagree with your methodology at this time, but you could
> have just made that single big file, include all those little files and
> still had a single load statement in each of your consumer source files.
> With compile caches the burden of loading all that code at startup is
> rather negligible :)

I've heard this before, and I don't understand why people say this. If
you have a 150k file you load before displaying a page, you've still
occupied the CPU with the task of loading a 150k file. What happens to
it afterward (compiling, compressing, caching, whatever) is another
issue. You've still loaded 150k of code. The question is whether you
actually need to load 150k of code from the start. If not, why waste the
resources?

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Structure of PHP files

2009-07-23 Thread Floyd Resler
'Tis true.  I just find dealing with the smaller files much easier.   
At the time I was using Komodo IDE and it would get very sluggish with  
the larger files.


Take care,
Floyd

On Jul 23, 2009, at 9:34 AM, Robert Cummings wrote:



Floyd Resler wrote:
When I first started programming in PHP I used the second method  
you  mentioned.  I had a single file I called utils.php and it  
contained  all the functions I could possibly need throughout my  
site.   Unfortunately, this file grew to be over 10,000 lines and  
most of the  time I only needed a couple of functions for each  
script I loaded.  I  have now abandoned that method and use a more  
modular approach.  I  have a lib folder that contains much smaller  
and specialized scripts  (mainly classes).  Now I only include what  
I need.  I found it much  easier to maintain than having a single  
file.


Not that I disagree with your methodology at this time, but you  
could have just made that single big file, include all those little  
files and still had a single load statement in each of your consumer  
source files. With compile caches the burden of loading all that  
code at startup is rather negligible :)


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Structure of PHP files

2009-07-23 Thread Robert Cummings


Floyd Resler wrote:
When I first started programming in PHP I used the second method you  
mentioned.  I had a single file I called utils.php and it contained  
all the functions I could possibly need throughout my site.   
Unfortunately, this file grew to be over 10,000 lines and most of the  
time I only needed a couple of functions for each script I loaded.  I  
have now abandoned that method and use a more modular approach.  I  
have a lib folder that contains much smaller and specialized scripts  
(mainly classes).  Now I only include what I need.  I found it much  
easier to maintain than having a single file.


Not that I disagree with your methodology at this time, but you could 
have just made that single big file, include all those little files and 
still had a single load statement in each of your consumer source files. 
With compile caches the burden of loading all that code at startup is 
rather negligible :)


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Structure of PHP files

2009-07-23 Thread Floyd Resler
When I first started programming in PHP I used the second method you  
mentioned.  I had a single file I called utils.php and it contained  
all the functions I could possibly need throughout my site.   
Unfortunately, this file grew to be over 10,000 lines and most of the  
time I only needed a couple of functions for each script I loaded.  I  
have now abandoned that method and use a more modular approach.  I  
have a lib folder that contains much smaller and specialized scripts  
(mainly classes).  Now I only include what I need.  I found it much  
easier to maintain than having a single file.


Take care,
Floyd

On Jul 23, 2009, at 5:36 AM, Sándor Tamás (HostWare Kft.) wrote:


Hi,

It isn't really a programming question, but rather a structural.

Let's suppose I have a PHP page, which is built by other PHP files'  
includes.


Which is the better approach:
 in a switch-like statement I include the required PHP files, which  
contain all the functions, and the HTML code to provide the  
functionality, or
 create a base PHP file which contains all the funcionality, and the  
PHP files only contain calls for these functions, and the HTML code?


I think the previous method gives more control and it is more  
repairable, but the later method gives more modularity. With your  
experiences, what method gives the better overall usability?


Thanks,
SanTa



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Structure of PHP files

2009-07-23 Thread Ford, Mike
> -Original Message-
> From: Dengxule [mailto:dengx...@gmail.com]
> Sent: 23 July 2009 10:53
> 
> 
> Hoping for the coming of the concept of PACKAGE. Seems that
> NAMESPACE will
> be introduced in PHP6.

Already present in 5.3, actually.


Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Structure of PHP files

2009-07-23 Thread Dengxule
2009/7/23 Sándor Tamás (HostWare Kft.) 

> Hi,
>
> It isn't really a programming question, but rather a structural.
>
> Let's suppose I have a PHP page, which is built by other PHP files'
> includes.
>
> Which is the better approach:
>  in a switch-like statement I include the required PHP files, which contain
> all the functions, and the HTML code to provide the functionality, or
>  create a base PHP file which contains all the funcionality, and the PHP
> files only contain calls for these functions, and the HTML code?
>
> I think the previous method gives more control and it is more repairable,
> but the later method gives more modularity. With your experiences, what
> method gives the better overall usability?
>
> Thanks,
> SanTa


As far as i experienced, the second method brings problems about the
"REQUIRE".

If you do put classes and functions directly in that "base PHP file", it
will looks fat , and you need a lot of copy/pastes.

If you just put a lot of "requires" in that "base PHP file", you may pay
attention about the PATH. Usage of "__FILE__" or "__autoload" may bring
confusions.

Hoping for the coming of the concept of PACKAGE. Seems that NAMESPACE will
be introduced in PHP6.


Dengxule
09/07/23


[PHP] Structure of PHP files

2009-07-23 Thread HostWare Kft.
Hi,

It isn't really a programming question, but rather a structural.

Let's suppose I have a PHP page, which is built by other PHP files' includes.

Which is the better approach:
  in a switch-like statement I include the required PHP files, which contain 
all the functions, and the HTML code to provide the functionality, or
  create a base PHP file which contains all the funcionality, and the PHP files 
only contain calls for these functions, and the HTML code?

I think the previous method gives more control and it is more repairable, but 
the later method gives more modularity. With your experiences, what method 
gives the better overall usability?

Thanks,
SanTa