Git Product home page Git Product logo

composer-envato's Introduction

Composer plugin for Envato

Packagist Packagist stats PHPStan

A Composer plugin to load WordPress themes and plugins from Envato.

💡 Always the latest version is installed, as Envato does not make other versions available. Package version locking can only be achieved by local persistent cache, not across hosts or users.

Installation

This Composer plugin adds a virtual package repository.

It is recommended to install it globally:

composer global require --update-no-dev szepeviktor/composer-envato

It can also be installed per-project:

composer require --update-no-dev szepeviktor/composer-envato

Configuration

Add all your Envato products as "packages" in either the local composer.json file or the global config.json file (located in $COMPOSER_HOME).

You can find the item-id at the end of product URL-s. e.g. https://themeforest.net/item/avada-responsive-multipurpose-theme/2833226

{
    "config": {
        "envato": {
            "token": "YOUR ENVATO PERSONAL TOKEN FROM https://build.envato.com/create-token",
            "packages": {
                "envato/avada-theme": {
                    "item-id": 2833226,
                    "type": "wordpress-theme"
                },
                "envato/layerslider-plugin": {
                    "item-id": 1362246,
                    "type": "wordpress-plugin"
                }
            }
        }
    }
}

💡 Please use the vendor name envato for consistency.

The personal token can also be read from an environment variable or a .env file. Create a .env file, where the composer.json file lives, and add the following:

ENVATO_TOKEN="<YOUR ENVATO PERSONAL TOKEN FROM https://build.envato.com/create-token>"

Usage

Once the plugin is installed and configured, you can simply install any of the listed products as Composer packages.

💡 Envato API has dynamic rate limiting

Behind the scenes

  1. This package is a Composer plugin
  2. In the activate method it creates an ArrayRepository with package data from config.json
  3. Package version is queried from Envato API
  4. When installing a package its URL is also queried from Envato API
  • Pretty package version is e.g. v1.2
  • Normalized package version is e.g. 1.2.0.0

composer-envato's People

Contributors

dannytaki avatar mcaskill avatar szepeviktor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

composer-envato's Issues

Installing embedded plugins in Avada

Thank you for this plugin, installation of Avada theme works great on my Bedrock WordPress website.

But ... it is very hard to install additional plugins.
For example, I get an error when I try install a plugin:

[Composer\Downloader\TransportException]                                                                                     
  The "https://api.envato.com/v3/market/buyer/download?item_id=1362246" file could not be downloaded (HTTP/1.1 404 Not Found)

The id of copied/pasted from the README file.

Is it an issue with the id of the plugin, a missing role of my access token?
How/where to get reliable plugins item-id and/or package names such as layerslider-plugin?

Thank you!

Incorrect folder structure after expanding zip

Hi,

Thanks for creating this Composer plugin!

I'm using composer with Roots Bedrock (wordpress) framework. I'm running into an issue how composer/this plugin expands a zip file from Envato. Any idea on how to rectify an issue when a plugin/package zip is getting expanded in an incorrect structure/format (wordpress doesn't recognize it as a plugin based on folder structure)?

For instance, the plugin is downloaded like so:

wp/plugins/plugin_package_name/plugin_name/CONTENTS

Vs. What Wordpress expects it to be:

wp/plugins/plugin_name/CONTENTS

Please advise.

Thanks!

Global installation of Composer plugin

This Composer plugin must be installed globally as it adds a virtual package repository.

I see that this notice was present early on.

Out of curiosity, I browsed the source code then I tested this plugin as a project requirement instead of installing it globally. It appears to work well.

What about this plugin requires it to be globally installed?

I have not looked at earlier versions; this was probably a necessity with Composer v1.

Furthermore, if this plugin can be safely installed per project, could the Envato personal access token be optionally outsourced to an environment variable (such as from a .env file loaded with vlucas/phpdotenv)?

How do use this with Trellis + Bedrock?

Following the install instructions after running composer global require --update-no-dev szepeviktor/composer-envato, I cannot find my config.json file the only file is composer.json in the directory /home/$USER/.config/composer.

image

Since this installs the file on my local directory how would this work with a Trellis+Bedrock set up? Would I have to manually run the installation command on the server? What happens when I have to re-provision server will it remove the szepeviktor/composer-envato plugin?

Design

  • require "composer-plugin-api": "^1.1" and "composer/installers": "^1.8"
  • figure out package type: wordpress-plugin or wordpress-theme -> what is in the response wordpress_theme, wordpress_plugin
  • version: https://api.envato.com/v3/market/catalog/item-version wordpress_theme_latest_version

Can't locate my plugin

Have I messed up on the installation of the plugin. Composer can't seem to get my Envato plugin.
I've ran composer global require --update-no-dev szepeviktor/composer-envato and created a config.json file and added the code

{
  "config": {
    "envato": {
      "token": "MY_TOKEN",
      "papckages": {
        "envato/woocommerce-pipedrive-crm-integration": {
          "item-id": 21721884,
          "type": "wordpress-plugin"
        }
      }
    }
  }
}

Then in my project's composer.json, I added "envato/woocommerce-pipedrive-crm-integration": "*" under "require":
Running composer update outputs:

dannytaki@DESKTOP-DANNY:~/Alliance-Chemical/site$ composer update

Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires envato/woocommerce-pipedrive-crm-integration, it could not be found in any version, there may be a typo in the package name.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
 - It's a private package and you forgot to add a custom repository to find it

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Signed and expiring URL-s from Envato API get into composer.lock

    "packages": [
        {
            "name": "envato/layerslider-plugin",
            "version": "6.9.2",
            "dist": {
                "type": "zip",
                "url": "https://marketplace-downloads.customer.envatousercontent.com/files/270888641/layersliderwp-6.9.2.installable.zip?response-content-dispositio....."
            },
            "type": "wordpress-plugin"
        }
    ],

If Composer cache is cleared the download from this URL will fail.

$ composer install --prefer-dist --no-suggest
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
    Finished: success: 0, skipped: 0, failure: 1, total: 1
Package operations: 1 install, 0 updates, 0 removals
  - Installing envato/layerslider-plugin (6.9.2): Downloading (0%)    Authentication required (marketplace-downloads.customer.envatousercontent.com):
      Username:

Error: Declaration of SzepeViktor\Composer\Envato\EnvatoPackage::getDistType() must be compatible with Composer\Package\Package::getDistType(): ?string in /var/www/html/vendor/szepeviktor/composer-envato/src/EnvatoPackage.php on line 53

Hello,
I try to install your composer-envato, but it doesnt work :-(
I extended the composer.json at the config array like:

    "envato": {
        "token": "PERSONAL-TOKEN",
        "packages": {
            "envato/avada-theme": {
                "item-id": 2833226,
                "type": "wordpress-theme"
            }
        }
    }

But after this I get an error:

PHP Fatal error: Declaration of SzepeViktor\Composer\Envato\EnvatoPackage::getDistType() must be compatible with Composer\Package\Package::getDistType(): ?string in /var/www/html/vendor/szepeviktor/composer-envato/src/EnvatoPackage.php on line 53

Fatal error: Declaration of SzepeViktor\Composer\Envato\EnvatoPackage::getDistType() must be compatible with Composer\Package\Package::getDistType(): ?string in /var/www/html/vendor/szepeviktor/composer-envato/src/EnvatoPackage.php on line 53

Any Idea?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.