Using Composer Packages in XenForo 2.1+ Addons Tutorial

Using Composer Packages in XenForo 2.1+ Addons Tutorial v2

No permission to download

Sim

Well-known member
Sim submitted a new resource:

Using Composer Packages in XenForo 2.1+ Addons Tutorial - How to use Composer packages in XenForo 2.1+ addons

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

XenForo v2 uses Composer behind the scenes to include certain packages used by the core software. As addon developers, we can include Composer packages in our own addons which will be autoloaded alongside those provided by the core.

In XenForo 2.0, we had to use extension points to do our...
Read more about this resource...
 

Xon

Well-known member
@Sim I recommend adding hashes.json and _metadata.json to the ignore list. Committing either of these into git is a nightmare if you need to work with another developer or rebase/merge at all.

I would also recommend a .gitattributes file with the contents;
Code:
*.php text eol=lf
*.js text eol=lf
(This forces consistent line-endings on commit, regardless of git client configuration. Just makes things easier)
 

Jeremy P

Well-known member
If you run composer upgrade it will upgrade packages based on the version constraints you have specified in your package.json file.
 

Jaxel

Well-known member
Getting this error:

The "https://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream: Connection timed out
 

Jeremy P

Well-known member
Can you open it in a browser? It loads fine for me, so I imagine it's some sort of networking/firewall issue between you and them.
 

Jaxel

Well-known member
Okay, I got it working... but it's not upgrading.

Currently I have google/cloud-firestore 1.4... and I know for a fact that 1.10 is available:

But its not upgrading:
Code:
composer upgrade google/cloud-firestore
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
 

Jaxel

Well-known member
Okay, doing that led to a whole bunch of stuff that I have no idea what it means:

Code:
composer upgrade google/cloud-firestore
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for google/cloud-firestore ^1.10.1 -> satisfiable by google/cloud-firestore[v1.10.1].
    - Conclusion: remove google/auth v1.4.0
    - Conclusion: don't install google/auth v1.4.0
    - google/cloud-firestore v1.10.1 requires google/cloud-core ^1.31 -> satisfiable by google/cloud-core[v1.31.0, v1.32.0, v1.33.0, v1.33.1, v1.34.0].
    - google/cloud-core v1.31.0 requires google/auth ^1.5.1 -> satisfiable by google/auth[v1.5.1, v1.5.2, v1.6.0, v1.6.1].
    - google/cloud-core v1.32.0 requires google/auth ^1.5.1 -> satisfiable by google/auth[v1.5.1, v1.5.2, v1.6.0, v1.6.1].
    - google/cloud-core v1.33.0 requires google/auth ^1.5.1 -> satisfiable by google/auth[v1.5.1, v1.5.2, v1.6.0, v1.6.1].
    - google/cloud-core v1.33.1 requires google/auth ^1.6 -> satisfiable by google/auth[v1.6.0, v1.6.1].
    - google/cloud-core v1.34.0 requires google/auth ^1.6 -> satisfiable by google/auth[v1.6.0, v1.6.1].
    - Can only install one of: google/auth[v1.5.1, v1.4.0].
    - Can only install one of: google/auth[v1.5.2, v1.4.0].
    - Can only install one of: google/auth[v1.6.0, v1.4.0].
    - Can only install one of: google/auth[v1.6.1, v1.4.0].
    - Installation request for google/auth (locked at v1.4.0) -> satisfiable by google/auth[v1.4.0].
 

Jeremy P

Well-known member
You have conflicting dependencies, meaning that two of your dependencies each require different versions of the same package. You'll likely want to upgrade all of your dependencies to the latest versions to resolve this.
 

Sim

Well-known member
Perhaps paste your require block from composer.json here so we can see what packages you are requiring?
 
Top