Hello, I'm with an big problem using cron jobs with my web system.
I developed my PHP system using MVC design pattern.
The classes are diveded in folders, like that:
public_html >
classes >
dao >
ClassNameDao.php
...
model >
ClassNameBean.php
...
controller >
ClassNameController.php
...
Every class is used by files/pages placed under public_html (like index.php)
So the usual php path is based on "public_html" folder, and some Controller class, for example, requires it's Model and Dao class and the DBConn class that connects to db.
Those classes are included like that:
PHP Code:
include_once 'classes/dao/UserDao.php';
include_once 'classes/dao/DBConn.php';
include_once 'classes/model/UserBean.php'
/*If the class I want to include is inside the same folder of the actual class being used (in this example 'classes/controller') I just need to put the name of the class and it's included with no problem.*/
include_once 'UserInfoController.php'
class UserController {
private $name, ...;
}
The problem is: When I use this Controller class for example, with my cron job php file (placed outside my public_html folder) my classes are not called correctly with the relative path in "include_once". I could rewrite the include of ALL my classes to absolute path, but it would took some time and will not be really good, since if I put my web system in another server, I would have to change all the path again.
I also tried to add the public_html folder to php path, but it still shows me errors with the 'include'. Can anyone point me an solution for this problem?