A
A
Alexander Taratin2018-06-09 14:18:35
PHP
Alexander Taratin, 2018-06-09 14:18:35

PHP file concatenator in C preprocessor style. Is there one?

I came across a crazy and merciless task to write a certain library, but the customer stubbornly wants to get it in one file without dependencies.
I began to write it like that, and after 300 lines it became already sad to become.
Is there a tool in nature that will recursively process include/include_once/require/require_once statements and collect everything into one file without stripping comments from the code?
If at the same time it will also be friends with the composer, it’s generally good, but one can no longer believe in such fairy tales.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Melkij, 2018-06-09
@melkij

Collect in phar - there will be exactly one file. Have you noticed that the composer itself is packaged in composer.phar?
Is it possible to present a library packed into phar as a library for composer - I can't answer.

D
Dmitry Entelis, 2018-06-09
@DmitriyEntelis

I haven't tried it myself, but maybe look in the direction of php.net/manual/en/book.phar.php ?
There, even in the comments, there is a piece of code that builds phar from the source folder.

S
synapse_people, 2018-06-14
@synapse_people

write a script that parses php code tokens, find and change T_INCLUDE, T_REQUIRE to the actual contents of the files.... done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question