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

New autoload method with $_composer_autoload_path #24

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/box-project-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# JBZoo Toolbox - Composer-Diff.
#
# This file is part of the JBZoo Toolbox project.
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#
# @license MIT
# @copyright Copyright (C) JBZoo.com, All rights reserved.
# @see https://github.com/JBZoo/Composer-Diff
#

name: Box Project Issue

on:
pull_request:
branches:
- "*"

env:
COLUMNS: 120
TERM_PROGRAM: Hyper

jobs:
phar:
name: Phar
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ 8.1, 8.2 ]
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: none
tools: composer

- name: Download Dependencies
run: make download-deps

- name: Show versions of tools
run: |
echo '1. which php'
which php
echo '2. php -v'
php -v
echo '3. which composer'
which composer
echo '4. composer --version'
composer --version
echo '5. /usr/local/bin/composer --version'
/usr/local/bin/composer --version
echo '6. php ./vendor/bin/box.phar --version'
php ./vendor/bin/box.phar --version

- name: Build Phar file
run: php ./vendor/bin/box.phar compile -v

- name: Trying to use the phar file
run: ./build/composer-diff.phar diff --help

- name: Upload Artifacts
uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: Reports - ${{ matrix.php-version }}
path: build/
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ build: ##@Project Install all 3rd party dependencies
@make create-symlink


download-deps:
composer update --optimize-autoloader --no-progress
curl https://github.com/box-project/box/releases/latest/download/box.phar \
--output ./vendor/bin/box.phar \
--connect-timeout 5 --max-time 10 --retry 5 --retry-delay 1 --retry-max-time 40 \
--location --fail --silent --show-error
chmod +x ./vendor/bin/box.phar


update: ##@Project Install/Update all 3rd party dependencies
$(call title,"Install/Update all 3rd party dependencies")
@composer update --optimize-autoloader --no-progress
Expand Down
25 changes: 12 additions & 13 deletions composer-diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,23 @@

use JBZoo\Cli\CliApplication;

const PATH_ROOT = __DIR__;

$vendorPaths = [
__DIR__ . '/../../autoload.php',
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/vendor/autoload.php',
];

foreach ($vendorPaths as $file) {
if (\file_exists($file)) {
\define('JBZOO_AUTOLOAD_FILE', $file);
break;
}
$cwd = isset($_SERVER['PWD']) && \is_dir($_SERVER['PWD']) ? $_SERVER['PWD'] : \getcwd();

// See https://getcomposer.org/doc/articles/vendor-binaries.md#finding-the-composer-autoloader-from-a-binary
if ((isset($_composer_autoload_path) && \file_exists($autoloadFile = $_composer_autoload_path))
|| \file_exists($autoloadFile = __DIR__ . '/../../autoload.php')
|| \file_exists($autoloadFile = __DIR__ . '/../autoload.php')
|| \file_exists($autoloadFile = __DIR__ . '/vendor/autoload.php')
) {
\define('JBZOO_AUTOLOAD_FILE', $autoloadFile);
} else {
throw new \RuntimeException("Could not locate autoload.php. cwd is {$cwd}; __DIR__ is " . __DIR__);
}

require_once JBZOO_AUTOLOAD_FILE;

$application = new CliApplication('JBZoo/Composer-Diff', '@git-version@');
$application->registerCommandsByPath(__DIR__ . '/src/Commands', __NAMESPACE__);
$application->setDefaultCommand('diff');

$application->run();
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.