For hosts with no Composer. How to add the API to a php script with require?

@modifiedcontent

So I suggested you install it by cloning repository from github because it seems like the easiest way to me (I may have been wrong).

You actually do not re-install the CRM in real sesne, you just organize the whole project setup in a way, that you can easily mange the dependencies. I mean after all before I wrote you the answer I started out from simple source clone from github. But I understand that might not be the most convenient thing for you. The good news is that that should not be a deal breaker.

If you want to keep your source and your update process intact, you can just go and try to install mautic api library differently (again I do not know your situation, so this might not be suitable for you):

  • Since you do not want to install mautic api library as part of existing “bundle” of dependencies, create another folder in mautic install called lib
  • Move to folder lib
  • Create composer.json file and put the following contents in:
{
  "require": {
    "mautic/api-library": "^3.0"
  },
}
  • Now run composer install --no-dev

Api library should be installed inside vendor directory composer created.

Now take the script, I created above, make sure you fix the path to vendor/autoload.php file at the top and edit the rest of the things where you see string “YOURVALUE” and give it a go (I did not test this and might not be the most optimal solution, but you should be able to use api library as documented in github repository here: < GitHub - mautic/api-library: Mautic API Library >).

1 Like