Question

I'm building a Symfony 1.4 project, and I'm attempting to use PEAR's Crypt_RSA package. Unfortunately, the package hasn't been updated in awhile, so instead of doing a simple pear install from the command line, I want to include it into my lib/vendor project path so that I can modify various pieces of code for use in PHP5. (It currently causes some warnings and strict errors, and I don't want to disable strict error checking).

I created an autoload.yml file in my config path that now contains the following:

autoload:
    Crypt_RSA:
        path:      %SF_LIB_DIR%/vendor/Crypt
        recursive: true

I then attempt to utilize the Crypt_RSA_KeyPair class (source) in the following manner:

$keyPair = new Crypt_RSA_KeyPair(128);

This results in the following error:

Warning: require_once(Crypt/RSA/ErrorHandler.php) [function.require-once]: failed to open stream: No such file or directory in /app_path/lib/vendor/Crypt/RSA/KeyPair.php on line 28

Fatal error: require_once() [function.require]: Failed opening required 'Crypt/RSA/ErrorHandler.php' (include_path='.:/opt/local/lib/php') in /app_path/lib/vendor/Crypt/RSA/KeyPair.php on line 28

Looking into the Crypt/RSA.php file (source), it has require_once calls for Crypt/RSA/ErrorHandler.php, Crypt/RSA/MathLoader.php, Crypt/RSA/Key.php, and Crypt/RSA/KeyPair.php, so I'm thinking I don't want symfony to autoload everything (i.e.: not autoload recursively) -- just the RSA.php file. However, the require_once calls are all specific to the folder containing the Crypt folder, meaning that the autoload needs to make sure that when RSA.php is loaded, it loads it from the proper path such that each of those files can be loaded correctly.

With this in mind, I tried a few different settings with no luck:

autoload:
    Crypt_RSA:
        path:      %SF_LIB_DIR%/vendor
        files:     [Crypt/RSA.php]
        recursive: false

and:

# moved "Crypt" folder into a subfolder named "pear"
autoload:
    Crypt_RSA:
        path:      %SF_LIB_DIR%/vendor/pear
        recursive: false

Each of these new attempts resulted in a different error whereby the Crypt_RSA_KeyPair class was simply not found altogether.

Fatal error: Class 'Crypt_RSA_KeyPair' not found in /app_path/lib/model/doctrine/sfDoctrineGuardPlugin/sfGuardUser.class.php on line 70

I've tried digging through the docs, but most of my Google searches point to Symfony docs for 1.0 rather than 1.4, and all of the docs are generally vague on autoloading vendor files.

I suppose another option would be to manually require_once the RSA.php file I need, but I'm guessing that would be breaking Symfony convention, and probably doing something harder than I should be (even though this autoloading thing seems to be harder than it should be too).

Was it helpful?

Solution

You might try to create your custom autoloader for the Crypt_RSA vendor package and register it in the ProjectConfiguration, as they presented in the Jobeet documentation (when using Zend Lucene).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top