Jump to content

How to use composer in your modules to install extra dependences for your module?


timnboys

Recommended Posts

How to use composer in your modules to install extra dependences for your module?

I am trying to flip my licensing around to enverido to use with my blesta(instead of WHMCS which I don't like using) does anyone know how to specify this:

https://github.com/timnboys/php/blob/master/composer.json

for enverido for my modules licensing? including my fraudrecord anti fraud module & etc?

or how would I go about putting enverido into my modules?

@cogative @Paul @Licensecart you got any ideas? as I don't use composer specifically in my modules and I know blesta uses it as well and don't want to confuse blesta by composer downloading the modules that might be already there? I just need help on figuring out how this will work and how to put it in my modules to replace WHMCS as my licensing system.

Link to comment
Share on other sites

Composer will only install from the composer.json in the current working directory, so  as far as I'm aware there shouldn't be any confusion between composer configurations for your modules and Blesta.

I'm not sure if there's a way for Blesta to automatically execute composer to install the module, or if you have to do it yourself manually. I know when I was doing it I just executed "composer install" after uploading the module files. 

Are you trying to use the Enverido PHP library to license your module? 

Link to comment
Share on other sites

34 minutes ago, cogative said:

Composer will only install from the composer.json in the current working directory, so  as far as I'm aware there shouldn't be any confusion between composer configurations for your modules and Blesta.

I'm not sure if there's a way for Blesta to automatically execute composer to install the module, or if you have to do it yourself manually. I know when I was doing it I just executed "composer install" after uploading the module files. 

Are you trying to use the Enverido PHP library to license your module? 

yes I am I want to make it easy on myself.

Link to comment
Share on other sites

Take a look at an example composer.json for a Blesta module here: https://github.com/enverido/blesta/blob/master/composer.json (@Paul might be able to provide a better example?) 

But to include the Enverido PHP library, you'd just add "enverido/php" under the "requires" section of the composer.json for the module. 

You could also remove GuzzleHTTP and PsySH from the composer.json, since they'll automatically be installed if you add "enverido/php".

Link to comment
Share on other sites

6 minutes ago, cogative said:

Take a look at an example composer.json for a Blesta module here: https://github.com/enverido/blesta/blob/master/composer.json (@Paul might be able to provide a better example?) 

But to include the Enverido PHP library, you'd just add "enverido/php" under the "requires" section of the composer.json for the module. 

okay what if I haven't used composer for my module yet and don't have a composer.json yet?

Link to comment
Share on other sites

See the edit I just made to my previous post, but essentially you could just throw that into your module's root directory, change some of the details to fit your module, add the "enverido/php" line to the "requires" section and you're pretty much good to go .

In the module files themselves (eg: "mymodule.php") make sure to make a "require_once" call to the autoload.php file that's generated by Composer. If you google a general tutorial on Composer I'm sure this'll be covered. But essentially you require_once the autoload.php file, and that file automatically includes all the libraries you installed using Composer. 

Link to comment
Share on other sites

if you want to use enverido is not required from your part any other library . because your module/plugin will only send data to  enverido server and check if is ok or not .

if you want to use guzzlle for curlhttp package , then create a vendor directory and add in it the packages, in your composed file you should make them as required  independencies, note that your files is coded and is not free so is better for you to include them in your project .

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...