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

Include external files. (Session Bridge)

Hey, I'm trying to figure out how I should import an external class. I assume it is done via the classloader which worked, but the issue I have is that this class requires a lot of other classes and the list is nearly endless. I wrote a small php script which works fine, but as soon as I try to implement it into phalcon it fails with missing classes.

https://gist.githubusercontent.com/Slind14/46461697e3c143a346a1/raw/21a998967fa8f39e531e43607b3e1ce55b367161/gistfile1.txt <- php script

This php code works fine when run alone. But when I add it to a Controller and add the "Autoloader.php" to the Phalcon loader (which works) it doesn't load the other required classes (e.g. Xenforo/Application, Zend/Controller/Request/Http, Zend/Registry).

What is the best way to get this working?

Thank you very much, Slind14



4.8k

Im not clearly getting your problem. Can you push your code?



5.7k

I created this small php script to get the session data from xenforo. It works fine and when I use it in another non mvc php script it works fine. But as soon as I try to use it with phalcon it doesn't include the required classes. e.g. XenForo_Autoloader, XenForo_Application..



4.8k

I think Phalcon does not know that these classes in directories exist. Have you tried registering the directories using loader like

$loader->registerDirs(
        array(
            __DIR__ . '/../../../xenforo//library/XenForo/Autoloader.php/', //->Always add trailing slash here
                        //other directories                           
        )
    )->register();


5.7k

I tried that already. After the 22th class I added to import I gave up.. Do I really need to add all files that Autoloader and later on the other classes require?



4.8k

can you pls post your code directory structure like

 [public]
    index.php
[modules]
    [module1]
    etc...


5.7k
edited Aug '14

https://i.imgur.com/vbz3b2p.png If you want the one from xenforo, too. Than I need to look for a command line directory tree generator.