Re: Organisation of classes
| From: | Peter Lauri | Date: | Thu, 02 Dec 2004 02:53:41 +0000 |
| Subject: | Re: Organisation of classes | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-203304@lists.php.net to get a copy of this message | ||
I have considered that, but I do not like that idéa :) I want php to
recognise what classes it needs to load. Have there been any improvment in
this area to PHP5? I use PHP4 for the moment, but will migrate to PHP5 soon.
As an "old" java programmer I feel that PHP is not that well deveolped. Was
hoping that it would be some sort of library system that could be used for
classes. Package?
/Peter
"John Holmes" <holmes072000@charter.net> skrev i meddelandet
news:41AE81DB.4070200@charter.net...
> Peter Lauri wrote:
>
> > For the moment I have all my classes saved in a file called classes.php
in a
> > subdirectory /classes/. I have started to get to many classes in the
same
> > file. In java I do this the default way, just naming them myclass.class.
Is
> > there a similar way to do this so that I do not need to include every
file
> > as a .php class in every php that I want to use the class?
>
> Save each class into its own name.class.php file.
>
> As for the includes, if there are a lot of classes and you actually need
> _all_ of them loaded, then just make one "include.php" that includes all
> of the class files and then just add "include('include.php')" into each
> script that needs these classes.
>
> You should really take a look at what classes need to be loaded in each
> page, though. If you have 10 classes, but a page only uses 3 of them,
> then it's a waste of time to load those other 7 classes. That's
> basically what you're doing now with everything in one file.
>
> Think about using extra classes that load the others that are needed for
> specific functios. Load a "show" class that'll load 4 of the 10 classes
> needed for showing records, load an "edit" class that'll load 7 of the
> 10 classes needed for editing, etc...
>
> --
>
> ---John Holmes...
>
> Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
>
> php|architect: The Magazine for PHP Professionals www.phparch.com