We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Fatal error: Call to undefined method Phalcon\Loader::registerPrefixes()

Hi all, I want to use the library HTMLPurifier. And I use command to create project default: phalcon create-project testabc I use the code for load HTMLPurifier :

$loader = new \Phalcon\Loader(); $loader->registerPrefixes([ 'HTMLPurifier' => LIBRARY_PATH.'/HTMLPurifier' ]); $loader->register();

But it error:

Fatal error: Call to undefined method Phalcon\Loader::registerPrefixes()

Please help me declared using HTMLPurifier.

I use phalcon version: 2.1.0

Loader of the Phalcon version 2.1 no longer supports registerPrefixes.

I strongly recommend to load it via composer as ezyang/htmlpurifier or other dependency manager.

edited Mar '16

If you dont use composer, just simply require

LIBRARY_PATH . '/HTMLPurifier.auto.php'

please guide me in detail

If you dont use composer, just simply require

LIBRARY_PATH . '/HTMLPurifier.auto.php'


9.3k
Accepted
answer

Forget Phalcon Loader and in your bootstrap file just add

require_once(LIBRARY_PATH . '/HTMLPurifier.auto.php');

which registers HTMLPurifier autoloader

THanks you so much

Why is that ?

If we want to use Phalcon Loader instead of composer one, we need it.

Loader of the Phalcon version 2.1 no longer supports registerPrefixes.

I strongly recommend to load it via composer as ezyang/htmlpurifier or other dependency manager.