Net_RouterOS
Net_RouterOS copied to clipboard
Error in Codeigniter
Succed at Localhost... but Failed to Connect at real Host... Userman use VPS...
Controller :
`function __construct(){ parent::__construct(); require_once(APPPATH.'libraries/PEAR2/Autoload.php'); }
function pelanggan_edit(){
try { $util = new PEAR2\Net\RouterOS\Util($client = new PEAR2\Net\RouterOS\Client('103.xxx.xxx.xxx', 'user', 'password')); } catch (Exception $e) { // mengalihkan halaman ke halaman data pelanggan redirect(base_url().'admin/pelanggan/data?alert=gagal_konek_userman'); }
}`
What is the error message?
im so gratefull for your response...
i had no Error message now... really failed to run try { } and its go to catch ... nothing happen in my router log...
You can output the exception for more details.
It sounds like there is an input rule in the filters that prevents API connectons. By default, MikroTik devices have a rule blocking all incoming connections from the internet. Maybe it's that.
i work it from my PC windows 10 with XAMPP v3.2.4... Userman server @ VPS with Static IP Public... PHP version: 7.3 ... Linux Web Server from rumahweb.com... @mikrotik VPS, have no filter rule...
i think, my problem in this area... require_once(APPPATH.'libraries/PEAR2/Autoload.php');
default structure codeigniter new library class must be load from 'autoload.php' $autoload['libraries'] = array('PEAR2\Autoload');
file : /public_html/application/libraries/PEAR2
but, Error : Unable to load the requested class: PEAR2\Autoload
and once again, its work in localhost but failed at website host.... i was try to change / slash or \ backslash, or uppercase and lowercase... all cant work
Check APPPATH and what the full path ends up as.
I suspect it might not end with a slash on your VPS, but end with a slash locally.
If you add a slash before "libraries", it should work regardless of whether there's a slash.
File position :
Local : C:\xampp\htdocs\khabilasa\application\libraries\PEAR2
Server : /public_html/application/libraries/PEAR2
if i write : require_once(APPPATH.'application/libraries/PEAR2/Autoload.php'); or $util = new application\PEAR2\Net\RouterOS\Util($client = new application\PEAR2\Net\RouterOS\Client('103.xxx.xxx.xxx', 'user', 'password'));
it will be failed even in the localhost
I meant you should check the APPPATH in the VPS, since that's where the problem is. The full path that ends up in the require_once may be wrong there, but correct on localhost.
The class names begin the same way (with "PEAR2") no matter the files' location.