Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove autoload.php #285

Merged
merged 4 commits into from
Jun 7, 2021
Merged

Remove autoload.php #285

merged 4 commits into from
Jun 7, 2021

Conversation

Art4
Copy link
Collaborator

@Art4 Art4 commented Jun 5, 2021

The src/autoload.php was created in #96 to allow using the library without Composer.

Since v1.7.0 we have dependencies to psr/http-client and psr/http-factory so the src/autoload.php stops working without manual installing this dependencies. The new recommended way to use this library without Composer is to use a service like php-download.com. Therefore, src/autoload.,php is no longer needed.

This PR removes the src/autoload.php.

@Art4 Art4 requested a review from kbsali June 5, 2021 09:14
@Art4 Art4 merged commit 4e55a35 into kbsali:v2.x Jun 7, 2021
@Art4 Art4 deleted the remove-autoload.php branch June 7, 2021 10:35
@Art4
Copy link
Collaborator Author

Art4 commented Jun 8, 2021

In case someone should ask for an installation possibility by hand (without Composer), please follow these instruction:
https://stackoverflow.com/a/40545971

It can be hard to follow the instruction, especially when there are many dependencies with sub-dependencies. (This work is usually done for you by Composer.)

So I have created a script install-redmine-api.sh (based on this instruction) that downloads the library with all dependencies for you. It will create a directory called vendor and generates the autoload.php file inside this vendor directory. Installation of PHP is required.

install-redmine-api.sh

#!/bin/sh

>&2 echo 'Download composer.phar file to local directory'

EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"

if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then
    >&2 echo 'ERROR: Invalid installer checksum'
    rm composer-setup.php
    exit 1
fi

php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php

if [ "$RESULT" != 0 ]
then
    >&2 echo 'ERROR: Could not install composer.phar'
    rm composer.phar
    exit $RESULT
fi

INSTALL_VERSION=""

if [[ $1 != "" ]]; then
    INSTALL_VERSION=":"$1;
fi

>&2 echo 'Download PHP library kbsali/php-redmine-api and create autoload.php'

php composer.phar require kbsali/redmine-api$INSTALL_VERSION --quiet
RESULT=$?

if [ "$RESULT" != 0 ]
then
    >&2 echo ''
    >&2 echo 'ERROR: Could not download kbsali/php-redmine-api'
    rm composer.json
    rm composer.phar
    exit $RESULT
fi

>&2 echo 'Remove composer.phar from local directory and other unused files'

rm composer.json
rm composer.lock
rm composer.phar

>&2 echo ''
>&2 echo 'Alright! You can now start using kbsali/php-redmine-api in your PHP script:'
>&2 echo 'require_once("vendor/autoload.php");'

Usage

Download the latest version:

$ ./install-redmine-api.sh

or download a specific version:

$ ./install-redmine-api.sh v1.8.1

Output

$ ./install-redmine-api.sh
Download composer.phar file to local directory
Download PHP library kbsali/php-redmine-api and create autoload.php
Remove composer.phar from local directory and other unused files

Alright! You can now start using kbsali/php-redmine-api in your PHP script:
require_once("vendor/autoload.php");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants