Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tehseen's avatar

How i can use php client library in laravel

Hi i want to use php client library in my laravel package. I want to use this amazon package in my laravel and use it.

https://developer.amazonservices.ca/doc/fulfillment/outbound/v20101001/php.html/141-8992690-9561209

How can i do this. Can any one please help.

0 likes
25 replies
D9705996's avatar

It looks like there is a package on Packagist that you can install that is the same as the link you provided.

If you run composer require amazon-mws-unofficial/mws-fulfillment-outbound-shipment and then follow the instructions in the README to configure you API keys, etc

tehseen's avatar

and how to use this in controller

tehseen's avatar

@d9705996 there is no use of the config file basically, so how we can put this or require this in our controller so that it can run.

Or the samples folder do noting perhaps i just need the config.php to load the package only it was working on my local machine is working fine. but we do not have the use of this package so might be we can include it manually

munazzil's avatar

You can use as like below in your app.blade.php.

<link href="{{ asset('yourpackagename') }}" rel="stylesheet">
tehseen's avatar

but is a library and its not in asset folder @munazzil, its amazon package for shipping services

tehseen's avatar

when i add the code in my controller it ask me that such controller is not found but i cannot or it should not have any controller we only require the amazon fulfillment package's config.php file

$service = new FBAOutboundServiceMWS_Client(
        AWS_ACCESS_KEY_ID,
        AWS_SECRET_ACCESS_KEY,
         $config,
        APPLICATION_NAME,
        APPLICATION_VERSION
        );
D9705996's avatar

@TEHSEEN - Whats the exact error you are getting? You don't necessarily need a separate controller. You would just start adding the sample code into your controller action. I would start working through the sample that is closest to what you want to achieve a line at a time and add the code to your controller and see what error is generated and then fix that problem before moving on to the next line of the sample until you get something that works. You can then refactor once you know that everything fundamentally works.

tehseen's avatar

Bro. i just need to pass my app's order to amazon for that i need to load config and some function of library but when i use the above code in my any controller it give me error where it write

$service = new FBAOutboundServiceMWS_Client(

laravel take the above function as controller but its not.

for the testing purpose i go through this tutorial in an separate folder with the instruction in this tutorial and is successfully work and orders are placed on amazon. the thing is i need it in laravel application bro. so as per your instruction i add the package via command and on button click i add the index.php code in my controller but it give me error.

Hope you understand.

Please advice.

D9705996's avatar

@TEHSEEN - Please share the error you are getting as I am not surewhat you mean by

laravel take the above function as controller but its not.

zion's avatar

Did you import (use) the class?

MikeRees's avatar

I think you mean that the file is not namespaced. This might cause some issues with autoloading as it's not PSR-4 compatible, but for now try doing new \FBAOutboundServiceMWS_Client( etc...

\ tells the code to run from the base namespace rather than the current file's namespace

tehseen's avatar

HI guys,

Can any one tell me how to solve this please.

D9705996's avatar

@TEHSEEN - Im not 100% sure exactly how to proceed. The package I suggest was to save you having to use the old include/require syntax.

The error you are getting is due to your controller being in the App\Http\Controllers namespace and it cant find a FBAOutboundServiceMWS_client class.

It might be as simple as adding a forward slash to say the root namespace (im not 100% on how psr-0 autoloading works)

$service = new \FBAOutboundServiceMWS_Client(

If you cant get this to work in a Laravel way you might just want to revert back using the old include/require that you had in your working test to get you up and running and then over time try and refactor

tehseen's avatar

@d9705996 thanks bro for you reply.

I was checking but didn't found any solution. perhaps i was running fine on localhost with custom php.

Might be i was doing some thing wrong but on my custom php code it was and its simple as it is. I guess the issue is with the including the library.

One more thing bro please clear me when i add the package on my project after that i get this on my console

@php artisan package:discover
Discovered Package: fideloper/proxy
Discovered Package: gloudemans/shoppingcart
Discovered Package: htmlmin/htmlmin
Discovered Package: mews/purifier
Discovered Package: rap2hpoutre/laravel-log-viewer
Discovered Package: roumen/sitemap
Discovered Package: laravel/socialite
Discovered Package: spatie/laravel-image-optimizer
Discovered Package: aloha/twilio
Discovered Package: laravel/tinker
Discovered Package: socialiteproviders/manager
Discovered Package: davejamesmiller/laravel-breadcrumbs
Package manifest generated successfully.

when i also update composer i also get this i afraid that this package also do something wrong in my project is that ? or its okay please advice bro

D9705996's avatar

@TEHSEEN - The messages you see aren't an issue. When you install a package it can automatically register in your application (you used to have to add entries to your app service provider manually ). The output just shows you what has registered

tehseen's avatar

@d9705996 thanks bro, some relief after read your above message. And for the main issue i try to fix this. If you have anything in this regard bro please let me know.

Thanks

D9705996's avatar

@TEHSEEN - No problem... you generally might have to tinker with this till it works as it's quite a unique use case but happy to throw in my two cents if needed

Please or to participate in this conversation.