Have you considered simply using require_once?
Also, you can find out if a class was defined by calling 'class_exists()'. In this way you might save something. The best way thought is what Miguel was saying: load the files conditionally with a logic. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com > -----Original Message----- > From: Tamás Árpád [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, April 03, 2002 9:51 PM > To: Miguel Cruz; Maxim Maletsky > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] Re: some kind of "library loader" > > > On Thu, 4 Apr 2002, Maxim Maletsky wrote: > > > You can try to load all those classes as texts into a db and then to > execute > > > the needed ones as eval()ed strings. It could be easy for you to create > the > > > logic because the PHP code are stings and are never included but > SELECTed. > > > Not sure if this could be wise to do, just throwing out an idea. > > > > Offhand I'm guessing the payoff wouldn't be great, because you'd lose the > > benefit of PHP's own code caching. Depends on how much of this voluminous > > code actually gets used on any one run, I suppose. But why not do the same > > thing with conditional includes, and then at least let PHP cache it? > > Thanks for your suggestion Maxim and Miguel. > > Unfortunately storing code in db wouldn't solve my problem, becuse then I > still had to recognise when the classes are really needed. Now in the 52k > lines of code we just have > $x = new SomeClass(); > $y = new OtherClass(); or > $result = AnotherClass::staticMethod(); statements, and we have many of > them. > That's why I'm searching for a sollution that we can use without rewrite all > these calls with the extension of a test if the needed class's definition > was or wasn't loaded before. > So I'd like to use conditional includes, and my first thought was that > somehow I can make it with a custom error handler, but unfortunately I > realized quickly it's not that simple. > Maybe you or someone can help, If I explain my problem in a little more > detail. > We have a "portal-creator" system (like many of you, I guess), with an own > developed template system. Of course we sell it to customers who have their > own needs. They create the designs, or tell us how the site should look, and > the created templates determine what template classes are needed for > generating the pages. The template classes require other "base" classes that > are responsible for handling the db storage. > We have about 430 classes (I misscalculated it in my firts mail), and they > have many "cross reference" to each other. So it's hard to know explicitly > if a class definition is needed, except of course at every new operator, and > static method call, but there are plenty of them. > Parsing of (almost) all of the php code takes about 1,5secs on an athlon 800 > cpu, which is far from reasonable. I expect that with conditional includes > at least half of the code wouldn't get parsed on a normal site, and even > less on a smaller site. > I wrote that I tried many code caches (I sent the results in deatils in > December), but none of them - except Zend Cache - made significant speed-up > (PHP-Accelerator also gave good results for speed, but I got many errors). > Unfortunatelly Zend Cache isn't affordable for many of our client, > especially the smaller ones, who don't need many of the features of the > system, so they would benefit much from the conditional includes. > > I hope someone who had the same situation can help, or at least I get > reinforcement, that I can't by-pass the hard way (to write an if clause > before every use of a class wether it was loaded or not). > Thanks for your help, > Arpi > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php