autoload

How to handle including needed classes in PHP

I'm wondering what the best practice is for handling the problem with having to "include" so many files in my PHP scripts in order to ensure that all the classes I need to use are accessible to my script. Currently, I'm just using includeonce to include the classes I access directly. Each of those would includeonce the classes that the...

Best solution for __autoload

As our PHP5 OO application grew (in both size and traffic), we decided to revisit the __autoload() strategy. We always name the file by the class definition it contains, so class Customer would be contained within Customer.php. We used to list the directories in which a file can potentially exist, until the right .php file was found. T...

autoload with namespace

I'm wondering how autoload will work with the namespace in PHP 5.3. Has anyone with 5.3 tested this? Do you have to include a file before you can use its namespace? Or will the class name be given with namespaces to autoload? Will these examples work correctly? //file My\Some\Object1.php is not included yet $obj1 = new My\Some\Object...

Make Flash movie autoload

Hello. I would like to embed a flash movie on my page but I would need it to autoload from the begining, not only when I reach it through page. I mean, I have a long page and the flash is about in the middle. It plays an animation with sound and I would like it to start itself, not only when I scroll down to it. Is this possible ? Thank...

Import package or autoloading for PHP?

Hello, everyone. What solution would you recommend for including files in a PHP project? There aren't manual calls of require/include functions - everything loads through autoload functions Package importing, when needed. Here is the package importing API: import('util.html.HTMLParser'); import('template.arras.*'); In this functi...

autoloader with upper and lowercase classname

I am using this class in php for autoloading. http://pastebin.com/m75f95c3b But when I have somewhere class Bar extends Foo And I have a file called foo.class.php it won't find the class. But when i chagne the filename to Foo.class.php it will find the class. I am trying to add some functionallity to my class to always find the fil...

Efficient PHP auto-loading and naming strategies

Like most web developers these days, I'm thoroughly enjoying the benefits of solid MVC architecture for web apps and sites. When doing MVC with PHP, autoloading obviously comes in extremely handy. I've become a fan of spl_autoload_register over simply defining a single __autoload() function, as this is obviously more flexible if you ar...

How to use Google Maps "auto-load" functionality ?

I began reading about Auto-loading a google map at: http://code.google.com/apis/ajax/documentation/#AutoLoading What's unclear to me is how to actually load the google map. I have tried: <script src="http://www.google.com/jsapi?autoload=%7B%22modules%22%3A %5B%7B%22name%22%3A%22search%22%2C%22version%22%3A%221.0%22%2C %22language%22%...

Why are autoload, load_all! and require all used in active_support.rb?

I was looking at active_support.rb to try to understand the load process it uses. It uses three loading methods: load_all!, autoload and require. Why use three different ways of loading in the same file? module ActiveSupport def self.load_all! [Dependencies, Deprecation, Gzip, MessageVerifier, Multibyte, SecureRandom, TimeWithZon...

How can you track the full sequence & order of 'require's in a Ruby app as a tree?

How can you display the hierarchy of 'require's that take place in a Ruby app? Some files require files which require additional files. However, by running an application in debug mode you only trigger a subset of required files - only the ones that are used by whatever subset of functionality your application is using at any given poi...

Autoload in Python

In the past I've used perl's AUTOLOAD facility for implementing lazy loading of symbols into a namespace, and wanted the same functionality in python. Traditionally the closest you appear to be able to get is to use a class and a __getattr__ class to achieve this sort of thing. However I've also tried rummaging around in sys.modules, a...

ExtJS: autoLoad does not work in IE

Using ExtJS 2.2.1, I've got a container element which is supposed to load a piece of HTML from the server using: autoLoad: { url: 'someurl' } This works fine in Firefox, but for IE7 this results in a syntax error in ext-all-debug.js at line 7170: this.decode = function(json){ return eval("(" + json + ')'); }; I fixed this b...

Auto-load function / class libraries when needed

First, a little background. The company I work for uses a massive function / class library, which gets included on every single page. Thousands and thousands of lines of functions, 90% of which probably won't even be called on a page. In an attempt to lighten the server load a little, I've been experimenting with smarter library setups....

How to upgrade Zend_Loader from 1.7 to 1.8?

I have been using this, and it works fine in 1.7, but not in 1.8. require_once('Zend/Loader.php'); Zend_Loader::registerAutoload(); It says it's deprecated, and that I should use Zend_Loader_Autoloader instead, but I can't seem to get it to work. Any suggestions? ...

__autoload mix up?

I have a server with many customers on, when I develop I include my init.php in which I have an __autoloader() function that includes the file with dir_name(__FILE__)."/classes/".$className for instance. But yesterday I saw that the server could not find the specific class, I restartat apache and then it worked again. Every customer ha...

PHP autoloader: ignoring non-existing include

I have a problem with my autoloader: public function loadClass($className) { $file = str_replace(array('_', '\\'), '/', $className) . '.php'; include_once $file; } As you can see, it's quite simple. I just deduce the filename of the class and try to include it. I have a problem though; I get an exception when trying to load a ...

Autoload with namespaces in PHP 5.3?

How do you use _autoload in PHP 5.3 with namespaces? I have a main autoload function in a namespace separate from my script. I'm also calling a class with a different namespace. (It's not surprising, but) It's not finding the autoload function. Do I have to recreate the autoload function for each namespace? That seems suboptimal. Thanks...

autoload and multiple directories

Hi I've just been looking at php's autoload() function. Seems a nice idea, but I'm not sure how it handles multiple directories. My current development basically has a library directory structure grouping classes into subdirectories by operation. I'm wondering I have to declare a include() for each directory ... which I really hope I ...

Can I autoload function files without classes in PHP?

My site is pretty large and I do not use PHP Classes, I do not understand OO good enough yet to re-write my site to use them however I would really like to use the __autoload($class_name) feature that classes use. I rely a lot on functions, I have different function files, forums.inc.php blogs.inc.php user.inc.php photos.inc.php general...

Do PHP opcode cache work with __autoload?

Sorry if this is basic, I am trying to learn as much as I can about OO in PHP and I am slowly learning how to use it (very limited). So I am wanting to know if __autoload() has any affect on PHP opcode cache's? ...