php - Error: Failed to open stream: No such file or directory -


i have code , same twilio.php library running on both local (xampp) server , vps:

checkconnection.php

<?php      // include twilio php library here     require '/twilio-php/twilio/autoload.php';     use twilio\rest\client;      $sid   = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // account sid www.twilio.com/console     $token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // auth token www.twilio.com/console      $client  = new twilio\rest\client($sid, $token);     $message = $client->messages->create(       'xxxxxxxxxxxxx', // text number       array(         'from' => 'xxxxxxxxxxxxx', // valid twilio number         'body' => 'mysql down!'       )     );      print $message->sid;  ?> 

the code runs locally, vps outputs following errors:

php warning: require(/twilio-php/twilio/autoload.php): failed open stream: no such file or directory in /var/www/html/thsportsmassagetherapy.com/mysql-monitor/checkconnection.php on line 4  php fatal error: require(): failed opening required '/twilio-php/twilio/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in **/var/www/html/thsportsmassagetherapy.com/mysql-monitor/checkconnection.php** on line 4 

locally, script , twilio libary located @

c:\xampp\htdocs\mysql-monitor\ 

on vps, located @

/var/www/html/thsportsmassagetherapy.com/mysql-monitor/ 

is path error or problem php settings?

to fix problem, set path autoload.php correctly.

for instance, if autoload.php located in /usr/local/lib/myapp.

require '/usr/local/lib/myapp/autoload.php'; 

it possible set include_path.

for example, in php file, do.

set_include_path('/usr/local/lib'); 

then instead of above require, do

require 'myapp/autoload.php'; 

or can do, use application framework symfony uses composer manage such things. when don't use symfony, still use composer.

why work hard when there tools out there make stuff easy?


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -