C
C
Crash2019-08-28 18:21:34
Yii
Crash, 2019-08-28 18:21:34

How to correctly connect an ancient library to a modern framework (PHP)?

There is one php file, which is a library for working with the API of one payment system (taken from the official site). The volume is 3000 lines, no namespaces, all classes follow each other, there is no mention of it on packagist.org. At first I wanted to connect it to web/index.php (I work with Yii2), but then I thought that it would be loaded on any request, any action. But on the other hand, when using require_once directly, I also don’t want to connect it, somehow it’s not in the style of modern development)
Which connection option is the most optimal?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2019-08-28
@Bandicoot

https://getcomposer.org/doc/04-schema.md#classmap
Put the library files in a separate directory (eg legacy-lib/) and register

"autoload": {
    "psr-4": {
        "App\\": "src/"
    },
    "classmap": ["legacy-lib/"]
},

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question