我正在尝试将此Woocommerce API library包含到我的项目中。这不是Laravel特定的包。但是,我在项目中包含这个问题时遇到了麻烦。
autoload-classmap.php
'WC_API_Client' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/class-wc-api-client.php',
'WC_API_Client_Authentication' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/class-wc-api-client-authentication.php',
'WC_API_Client_Exception' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/exceptions/class-wc-api-client-exception.php',
'WC_API_Client_HTTP_Exception' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/exceptions/class-wc-api-client-http-exception.php',
'WC_API_Client_HTTP_Request' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/class-wc-api-client-http-request.php',
'WC_API_Client_Resource' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/resources/abstract-wc-api-client-resource.php',
'WC_API_Client_Resource_Coupons' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/resources/class-wc-api-client-resource-coupons.php',
'WC_API_Client_Resource_Custom' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/resources/class-wc-api-client-resource-custom.php',
'WC_API_Client_Resource_Customers' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/resources/class-wc-api-client-resource-customers.php',
'WC_API_Client_Resource_Index' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/resources/class-wc-api-client-resource-index.php',
'WC_API_Client_Resource_Order_Notes' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/resources/class-wc-api-client-resource-order-notes.php',
'WC_API_Client_Resource_Order_Refunds' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/resources/class-wc-api-client-resource-order-refunds.php',
'WC_API_Client_Resource_Orders' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/resources/class-wc-api-client-resource-orders.php',
'WC_API_Client_Resource_Products' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/resources/class-wc-api-client-resource-products.php',
'WC_API_Client_Resource_Reports' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/resources/class-wc-api-client-resource-reports.php',
'WC_API_Client_Resource_Webhooks' => $vendorDir . '/woothemes/woocommerce-api/lib/woocommerce-api/resources/class-wc-api-client-resource-webhooks.php',
我想知道,因为这不是Laravel包,我是否需要在控制器中包含此文件以及我如何处理这个?
答案 0 :(得分:2)
"require": {
"woothemes/woocommerce-api": "dev-master"
},
"require-dev": {
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"app\\": "app/"
},
"files":[
"vendor/woothemes/woocommerce-api/lib/woocommerce-api.php"
]
},
因此需要woocommerce api然后将main require文件添加到composer的files数组中。那么你可以编写dumper-autoload,并将使用该库。
答案 1 :(得分:0)
我已经打电话了
composer require automattic/woocommerce
然后在我的PHP文件中:
use Automattic\WooCommerce\Client;
$woocommerce = new Client(
'http://example.com',
'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
);
并且没有任何问题