2
votes

my file structure for phalcon is something like this

--app
-----controllers
-----models
-----views
-----functions
-----libraries

where functions and libraries folder contains some third party scripts like facebook log in etc, when I include the script in my controller classes, I did

include "../functions/facebook.php"

but it gives a file not found error.

How should I include files in the controller classes?

1
This thing is in the controller directory? It seems obvious, but I don't give 1 point new users the benefit of the doubt: does this file facebook.php exist? - Jori
Can you give us the exact location of your controller file that is having problems doing the include and the exact location of facebook.php? - Levi Morrison
controller file is in app/controllers/SessionController.php facebook.php is in app/functions/facebook.php - user3633801
actually adding a global DIR in the include directory helps finding the file. But the functions included in the php script is not included as it gives Fatal error: Call to undefined function foo(). - user3633801
found my error, in my php file I did <? instead of <?php, so it didn't read it as php script. - user3633801

1 Answers

3
votes

Ideally you should be using an autoloader Phalcon provides for automatically loading classes.

For non-classes, did you try using full path?

include __DIR__ . "/../functions/facebook.php";