Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set include path of file when running script from cmd

I m trying to run php file from the command fine. here files are not included. Whrn I run php script from the browser its works perfect but when I run it from cmd then its giving error for that included file

PHP code

require("include/config.php");
include_once('include/classes/dbclass.php');
include_once('include/classes/send_emails.php');

Here suppose I put the code of dbclass.php file into main one and removed include_once('include/classes/dbclass.php'); line than there is no problem. So how to write include path or set include file when we used cmd to run php script

like image 466
kreya Avatar asked Jan 07 '15 09:01

kreya


1 Answers

Your setup may have different php.ini option files for cmdline and web use, you can either add the right include_path to the cmdline ini file (/etc/php5/cli/php.ini in my case), or pass it as a command line parameter:

php -d include_path=... script.php
like image 62
Hartmut Holzgraefe Avatar answered Sep 19 '22 19:09

Hartmut Holzgraefe