solved Where to use namespace?

sbhadauria
@sbhadauria
7 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: 03/19/18 06:25:32PM
paul
@paul
7 years ago
4,323 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
7 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: 12/15/17 07:11:21AM
brian
@brian
7 years ago
10,136 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
7 years ago
129 posts
Thanks @brian

Tags