drwghu6386 2015-03-28 19:47
浏览 49
已采纳

PHP Custom Class,PayPal API,Mailgun API,Easypost API。 他们可以一起工作吗?

I have an ecommerce site that i am building for a client. This site had previously worked perfectly fine using procedural functions and curl to make the calls to Paypal. I download the Mailgun and Easypost API manual and installed manually. DOwn the road, I wanted to update the site to utilize PDO & OOP. I have done a fair job at getting the foundation laid. Now it is time to start making calls to the various API's.I installed everything using composer and currently run a dual autoloader. The composer autoload and then beneath it a custom autoload to load my classes. Now, when I call on the PayPal API, I get the following error:

Fatal error: Class 'Paypal\Rest\ApiContext' not found in /var/www/html/myla-dev/shoppingCartFinalize.php on line 18 

I think what is happening is my autoloader is trying to load this rather than the composers autoloader. Here is where the autoloading is occurring:

init.php

require __DIR__.'/core/functions/general.php';
function autoLoader ($class) {
  if (file_exists(__DIR__.'/core/classes/'.$class.'.php')) {
    require __DIR__.'/core/classes/'.$class.'.php';
  }
}
spl_autoload_register('autoLoader');
require __DIR__.'/vendor/autoload.php';

This file sits in project root directory and is then required at the top of every file.

File Structure

core
--classes
----Alert.php
----....
--functions
----general.php
vendor
--composer
--easypost
--guzzle
--mailgun
--symfony
--paypal
--autoload.php
index.php
init.php
...

composer.json

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/EasyPost/easypost-php"
    }
  ],
  "require": {
    "php": ">=5.3.0",
    "easypost/easypost-php": "dev-master",
    "ext-curl": "*",
    "ext-json": "*",
    "paypal/rest-api-sdk-php":"*",
    "mailgun/mailgun-php": "dev-master"
  }
}

Any and all assistance is appreciated. If you feel like writing code, GREAT, but that is not what I am asking for. That is my job, but help with reworking to make it work would be awesome.

Thanks

  • 写回答

1条回答 默认 最新

  • doufu1939 2015-04-01 05:19
    关注

    It ended up being a simple syntax error. After I dumped and updated composer it still failed to work, so I just copied the code from the installation wiki. It worked so I composer their code to mine and I was missing a backslash in my call to the wiki. Thank you for your assistance though.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度