solved Where to use namespace?

sbhadauria
@sbhadauria
4 years ago
129 posts
I am creating a new module to use third party API. But to implement this API I need to use namespace (namespace Google\Api).
So where can I put namespace code?
updated by @sbhadauria: 19 Mar 2018 06:25:32PM
paul
@paul
4 years ago
4,238 posts
Put it in a folder inside the module. Various Jamrom module put third party code in module subfolders, for instance, take a look at the jrCore/contrib or jtSystemTools/tools folders
Hope that helps


--
Paul Asher - JR Developer and System Import Specialist
sbhadauria
@sbhadauria
4 years ago
129 posts
Hi @paul, thanks for reply.

Third party API using the namespaces and we need to define the namespace on top of page where we are calling the functionality.

namespace Google\Api\CustomTargetingService;
require APP_DIR . '/modules/xtCustom/lib/GoogleAPI/vendor/autoload.php';

I am not getting any namespace in jamroom.
updated by @sbhadauria: 15 Dec 2017 07:11:21AM
brian
@brian
4 years ago
10,000 posts
At the top of xtCustom/include.php:

use Google\Api\CustomTargetingService;
require APP_DIR . '/modules/xtCustom/lib/GoogleAPI/vendor/autoload.php';



--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
sbhadauria
@sbhadauria
4 years ago
129 posts
Thanks @brian

Tags