Skip to content

Incorrect autoload path in util/convert.php and bulk_convert.php prevents script from running in Composer projects #11

@CreativeNative

Description

@CreativeNative

Describe the bug
The util/convert.php and bulk_convert.php scripts are trying to load the Composer autoload file using this code:

util/convert.php (line 227):
require_once(dirname(dirname(__DIR__)) . '/vendor/autoload.php');

and

util/bulk_convert.php (line 101)
require_once (dirname(__DIR__).'/vendor/autoload.php');

However, this relative path is incorrect for the typical project structure and causes a fatal error because the file cannot be found.

To Reproduce
Run the script via php convert.php from that location /vendor/tecnickcom/tc-lib-pdf-font/util$ php convert.php
It tries to require a non-existing file at vendor/vendor/autoload.php (because of the relative path).
The script crashes.

Expected behavior
The script should correctly locate the project’s root vendor/autoload.php file regardless of its nested location. A better path resolution would be:

require_once dirname(__DIR__, 4) . '/vendor/autoload.php';

Logs
PHP Warning: require_once(/path/to/vendor/tecnickcom/vendor/autoload.php): Failed to open stream: No such file or directory in /vendor/tecnickcom/tc-lib-pdf-font/util/convert.php on line 227

Environment:
OS: Ubuntu 20.04 (typical Linux)
PHP version: 8.2
Version: tc-lib-pdf-font latest (as of [date])

Additional context
This bug breaks the ability to use the conversion utility in typical Composer-based project layouts. Fixing the relative path to correctly point to the root vendor/autoload.php will improve usability and maintainability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions