T
T
to_east2019-05-12 14:44:23
PHP
to_east, 2019-05-12 14:44:23

PHP merge into one file project on composer?

Greetings Toaster Members!
I wanted to ask if there are projects with similar functionality. Do you just need to combine all the project classes into one file, respecting the connection order?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
OnYourLips, 2019-05-12
@OnYourLips

In the PHP ecosystem, this is done through the PHAR archive.
You can see an example in some phpunit.

T
to_east, 2019-05-12
@to_east

Here it seems to be https://www.php.net/manual/ru/function.get-declare... displays a list of classes, I think that you can weaken your build script based on this, just pre-filter
In general, it's better to use the loader itself Composer, I found the getClassMap() method, which displays a list of loaded classes:

<?php

$loader = require_once __DIR__ . '/../vendor/autoload.php';
$loader->getClassMap();

Then, of course, you can parse with a regex and pull out all the classes into one file, but it’s not clear what is connected with the connection order, starting from the list of this method, I’ll venture to assume that the dependency stack goes from bottom to top, because my root class is at the top of the rest in the same namespace, so that this doesn’t happen that the class definition is below the call.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question