Re: Organisation of classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux