Getting started with Mautic API

Trying to use the Composer way to install the PHP API library that is apparently still required. Running the command composer require mautic/api-library as user, not root, from the Mautic directory, results in following error:

No composer.json in current directory, do you want to use the one at /home/myusername/public_html? [Y,n]?

That’s a no…

What can I try next? Should I copy a composer.json from somewhere else (?) and upload to my Mautic installation folder so Composer can work its “magic”?

Edit:

I copied the composer.json from the API library on Github to my Mautic folder and “simply ran” the magic Composer command again, resulting in the following error message:

Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See Deprecating Packagist.org support for Composer 1.x
Using version ^3.0 for mautic/api-library
Root package ‘mautic/api-library’ cannot require itself in its composer.json

Edit2:

First Composer update attempt with composer self-update --stable

[Composer\Downloader\TransportException]
The “https://getcomposer.org/versions” file could not be downloaded: allow_
url_fopen must be enabled in php.ini (https:// wrapper is disabled in the s
erver configuration by allow_url_fopen=0
failed to open stream: no suitable wrapper could be found)

Edit3:

After enabling allow_url_fopen, Composer self-update runs into permission errors. So this update has to be run as root? Composer self-update to version 2.1.6 went through run as root.

Edit4:

After updating Composer and adding the composer.json and composer.lock from the latest Mautic package to my Mautic installation folder, running composer require mautic/api-library again, again as user instead of root, produces this error:

Using version ^3.0 for mautic/api-library
./composer.json has been updated
Running composer update mautic/api-library
Loading composer repositories witUpdating dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Root composer.json requires mautic/core-lib ^3.0 → satisfiable by mautic/core-lib[3.x-dev].
- mautic/core-lib 3.x-dev requires symfony/console ~3.4.0 → found symfony/console[v3.4.0-BETA1, …, 3.4.x-dev] but the package is fixed to v4.4.26 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

Edit5:

Trying again with composer require mautic/api-library --with-all-dependencies produces the following error:

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 67108864 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSetGenerator.php on line 110

Apparently Composer needs a PHP memory limit of 2G, which seems insane to me…

After eventually setting the memory limit to 3G (!), something finally went through, producing the following error:

Your requirements could not be resolved to an installable set of packages.

Problem 1
- Root composer.json requires mautic/core-lib ^3.0 → satisfiable by mautic/core-lib[3.x-dev].
- mautic/core-lib 3.x-dev requires willdurand/oauth-server-bundle dev-release-0.0.3 → found willdurand/oauth-server-bundle[dev-master, 0.0.1] but it does not match the constraint.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

Note that Composer is looking for packages required by mautic/core-lib 3.x-dev; I had already upgraded to Mautic 4 and am using the most recent composer.json file I could find.

Edit6:

Apparently Mautic is doubling down on Composer. There is command composer update mautic/core --with-dependencies that looks usable for my situation and maybe I can find an updated composer.json here somewhere?

composer update mautic/core --with-dependencies also requires 3G+ memory in PHP and produces the same errors as before:

Loading composer repositories with package information
Package “mautic/core” listDependency “composer/installers” is also a root requirement. Package has not been listed as an update argument, so keeping locked at old version. Use --with-all-dependencies (-W) to include root dependencies.
Dependency “symfony/var-dumper” is also a root requirement. Package has not been listed as an update argument, so keeping locked at old version. Use --with-all-dependencies (-W) to include root dependencies.
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Root composer.json requires mautic/core-lib ^3.0 → satisfiable by mautic/core-lib[3.x-dev].
- mautic/core-lib 3.x-dev requires willdurand/oauth-server-bundle dev-release-0.0.3 → found willdurand/oauth-server-bundle[dev-master, 0.0.1] but it does not match the constraint.

Note that contrary to these warnings, I already had --with-all-dependencies in the command.

Edit7:

Does it have something to do with this bug? Same bug here - the only page that comes up if you google “willdurand/oauth-server-bundle dev-release-0.0.3”.

@rcheesley had answered this bug with ‘Please ensure that you are using Composer 1 - we will not be supporting Composer 2 until Mautic 4.’ As you can see above, Composer 1 didn’t work; we are now on Composer 2 with Mautic 4.

Where is ‘willdurand/oauth-server-bundle dev-release-0.0.3’ required? I don’t see it in the composer.json for Mautic 4 and can’t find it anywhere in files in my Mautic installation. If I knew where that requirement came from I could try if changing it to 0.0.1 would fix this error.

willdurand/oauth-server-bundle is apparently a ‘Server side implementation of the OAuth 1.0 protocol’. OAuth 1.0 is no longer in Mautic 4. Why is Composer even requiring this?

willdurand/oauth-server-bundle 0.0.3 is required by ‘mautic/core-lib 3.x-dev’. What is ‘mautic/core-lib 3.x-dev’ and should it be in Mautic 4?

Edit8:

Tried again with composer update mautic/core --with-all-dependencies - note ‘all’ included. Still stalls on the same error:

Your requirements could not be resolved to an installable set of packages.

Problem 1
- Root composer.json requires mautic/core-lib ^3.0 → satisfiable by mautic/core-lib[3.x-dev].
- mautic/core-lib 3.x-dev requires willdurand/oauth-server-bundle dev-release-0.0.3 → found willdurand/oauth-server-bundle[dev-master, 0.0.1] but it does not match the constraint.