We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Can not find class

Oh man. I really tried everything. I also read all the posts here in the forum, but I don't understand what going wrong.

I try to integrate PHP-FFMpeg in my project. But if I call the class FFMpeg php throws an error.

In the script "/apps/frontend/logic/Film.php" I try to call the class "FFMpeg":

    use FFMpeg;
    ....
    public static function convert(){
        ...
        $ffmpeg = FFMpeg::create();
        ...
    }

In the file "/apps/frontend/module.php" I registered the namespace "FFMpeg":

$loader = new Loader();

        $loader->registerNamespaces(array(
            'Itxura4\Frontend\Controllers' => __DIR__ . '/controllers/',
            'Itxura4\Frontend\Models' => __DIR__ . '/models/',
            'Itxura4\Frontend\Logic' => __DIR__ . '/logic/',
            'FFMpeg' => __DIR__ . '/../lib/'
        ));
        $loader->register();

All the scripts of FFMpeg are located in the folder: "/apps/lib/"

But all the time I just get an fatal error:

Fatal error: Class 'FFMpeg' not found in C:\xampp2\htdocs\itxura4\apps\frontend\logic\Film.php on line 115

What is wrong?

Thank you guys for helping. Benni



7.9k

please provide FFMpeg class name and its namespace.

logically if you include FFMpeg it should be using composer (cf https://github.com/PHP-FFMpeg/PHP-FFMpeg/blob/master/composer.json#L36) Loader in phalcon is PSR4 not PSR0 so you should do

$loader = new Loader();

        $loader->registerNamespaces(array(
            'Itxura4\Frontend\Controllers' => __DIR__ . '/controllers/',
            'Itxura4\Frontend\Models' => __DIR__ . '/models/',
            'Itxura4\Frontend\Logic' => __DIR__ . '/logic/',
            'FFMpeg' => __DIR__ . '/../lib/FFMpeg'
        ));
        $loader->register();

better should be to use composer autoloader or a phalcon one which uses composer files