ballhogjoni Posted August 24, 2013 Share Posted August 24, 2013 I running a script which autoloads ShippingManager. An instance of ShippingManager calls a function that should create a new instance of another class that is located in the orders folder. I am getting Fatal error: Class 'MarketplaceWebServiceOrders_Client' not found. How do I fix this? autoload code: set_include_path(get_include_path() . PATH_SEPARATOR . 'orders' . PATH_SEPARATOR . 'feeds' . PATH_SEPARATOR . '../lib'); function __autoload($className) { $filePath = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; $includePaths = explode(PATH_SEPARATOR, get_include_path()); foreach ($includePaths as $includePath) { if (file_exists($includePath . DIRECTORY_SEPARATOR . $filePath)) { require_once $filePath; return; } } } handle_shipping.php <?php include_once ('path/to/config.php'); $shipping_manager = new ShippingManager("ESHIP-" . date('Ym23') . ".txt"); if ($shipping_manager->getShippingFileFromFTP(URL, USER, PASS)) { $shipping_manager->createShippingCSVFile(); } ShippingManager function that is called from the createShippingCSVFile function. The class MarketplaceWebServiceOrders_Client isn't being autoloaded. private function __getOrderItemId() { $service = new MarketplaceWebServiceOrders_Client(); $orderItems = new MarketplaceWebServiceOrders_Model_ListOrderItemsRequest(); $orderItemList = $orderItems->getOrderItem(); foreach ($orderItemList as $orderItem) { print_r($orderItem->getOrderItemId()); } } Quote Link to comment Share on other sites More sharing options...
requinix Posted August 24, 2013 Share Posted August 24, 2013 Either you have the wrong class name, your autoloader isn't working, or your autoloader isn't finding the right file. Given how little you've posted, I don't know which of those it is. Have you tried... say... debugging? Your autoloader would be the first place to start. Quote Link to comment Share on other sites More sharing options...
Solution ballhogjoni Posted August 25, 2013 Author Solution Share Posted August 25, 2013 Either you have the wrong class name, your autoloader isn't working, or your autoloader isn't finding the right file. Given how little you've posted, I don't know which of those it is. Have you tried... say... debugging? Your autoloader would be the first place to start. Sorry i didn't post much, but your comment was all I needed. I realized that the ShippingManager function was calling MarketplaceWebServiceOrders_Client() from a different location. I just altered my include path to this: set_include_path(get_include_path() . PATH_SEPARATOR . 'orders' . PATH_SEPARATOR . '../orders' . PATH_SEPARATOR . 'feeds' . PATH_SEPARATOR . '../feeds' . PATH_SEPARATOR . '../lib'); Quote Link to comment Share on other sites More sharing options...
trq Posted August 25, 2013 Share Posted August 25, 2013 For starters, this: if (file_exists($includePath . DIRECTORY_SEPARATOR . $filePath)) { require_once $filePath; return; } would need to be: if (file_exists($includePath . DIRECTORY_SEPARATOR . $filePath)) { require_once $includePath . DIRECTORY_SEPARATOR . $filePath; return; } But yeah, some debugging would help. Quote Link to comment Share on other sites More sharing options...
trq Posted August 25, 2013 Share Posted August 25, 2013 Sorry i didn't post much, but your comment was all I needed. I realized that the ShippingManager function was calling MarketplaceWebServiceOrders_Client() from a different location. I just altered my include path to this: set_include_path(get_include_path() . PATH_SEPARATOR . 'orders' . PATH_SEPARATOR . '../orders' . PATH_SEPARATOR . 'feeds' . PATH_SEPARATOR . '../feeds' . PATH_SEPARATOR . '../lib'); Oh, that looks terribly inefficient (and autoloading is a notorious bottleneck if not done well). Just use absolute paths to your libs. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.