Share » Forums » Extensions » Add rules to autoload

Add rules to autoload

Add rules to autoload

Tuesday 14 June 2011 1:43:22 am - 4 replies

Author Message

Jérôme Vieilledent

Tuesday 14 June 2011 1:50:52 am

Hi Damien

Yes, this is possible, but not inside extensions. You will need to alter your config.php.

Here's an extract from config.php-RECOMMENDED :

/*
   CUSTOM AUTOLOAD MECHANISM
   -------------------------
   It is also possible to push a custom autoload method to the autoload
   function stack. Remember to check for class prefixes in such a method, if it
   will not serve classes from eZ Publish and eZ Components.
   Here is an example code snippet to be placed right in this file, in the case
   you would be using your custom Foo framework, in which all PHP classes would be
   prefixed by 'Foo' :

   <code>
       ini_set( 'include_path', ini_get( 'include_path' ). ':/usr/lib/FooFramework/' );
       require 'Foo/ClassLoader.php';

       function fooAutoload( $className )
       {
          if ( 'Foo' == substr( $className, 0, 3 ) )
          {
              FooClassLoader::loadClass( $className );
          }
       }
       spl_autoload_register( 'fooAutoload' );
   </code>
*/

Damien MARTIN

Tuesday 14 June 2011 1:58:18 am

Thanks Jérôme.

It will save my day :)

Marko Žmak

Tuesday 14 June 2011 7:32:10 am

Hi Damien, in fact you can use external libraries without altering config.php, see here:

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Damien MARTIN

Wednesday 15 June 2011 4:58:25 am

Hi Damien, in fact you can use external libraries without altering config.php, see here:

It looks interesting too. I'll look at this when I'll have some time

Thanks

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu