How to use 3d party packages from ext/vendor?

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
andreask
Registered User
Posts: 752
Joined: Fri Feb 27, 2009 6:13 pm
Name: Andreas

How to use 3d party packages from ext/vendor?

Post by andreask »

Hi,

Please excuse my ignorance.
I wont to use a 3d party package installed by composer to my ext/vendor but I do not know how to use it.

Do I just include() or do I go through config.yml.
And if the second case applies then are there any specific things I need to take care of?

An example would be hughly appreciated.

Thank you for your help!
Here is what I am working on right now...
Inactive User Manager for phpBB
Give it a try...
If you would like to buy me a bier ;) for my work I will drink it on a hot summer day and thank you!!!
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: How to use 3d party packages from ext/vendor?

Post by david63 »

The first thing is that you need to have it as a requirement in your composer.json file (the details should be with the package)

Code: Select all

"require": {
        "php": ">=7.3.0",
        "composer/installers": "~1.0",
		"vendor/package": "^0.2.1"
    },
Then you will need to run composer to include it in your extension.

Then when you want to use it in your extension's files just have use vendor\package\class;
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
andreask
Registered User
Posts: 752
Joined: Fri Feb 27, 2009 6:13 pm
Name: Andreas

Re: How to use 3d party packages from ext/vendor?

Post by andreask »

Ah! I see!

Thank you very much david63!
Here is what I am working on right now...
Inactive User Manager for phpBB
Give it a try...
If you would like to buy me a bier ;) for my work I will drink it on a hot summer day and thank you!!!
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: How to use 3d party packages from ext/vendor?

Post by 3Di »

You should be able to use
$vendorClass = new \package\class;
$method = $vendorClass->method();

as an option, look at the vendor's docs.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
Post Reply

Return to “Extension Writers Discussion”