safe
safe copied to clipboard
New, autoloader-centric file structure
Aka. for machines only
repo/
├─ generated/
│ ├─ src/
│ ├─ functions.php
- all classes go (generated or copied) in
src
directory as per PSR-4 - all functions go (generated or copied) into
functions.php
file - keep
generated/functionsList.php
- deprecated things get a PHPDoc tag
/**
* @deprecated Reason, date, version ...
*/
Resulting Composer config.
"autoload": {
"psr-4": {
"Safe\\": [
"generated/src/"
]
},
"files": [
"generated/functions.php"
]
},
All other directories could be excluded from distribution.
Would you support a PR that modifies the generator?
@Kharhamel I understand it may hurt your feelings.
Asked how to do it: https://github.com/rectorphp/rector/issues/7131
I am not sure I understand the link with rector but yes, that new structure looks good, i would definitly like a PR to do that, especially if it solves issues like #253.
However I am thinking really hard about generating several directories of functions, to be loaded depending of the php version of the client. Do you think we could do something like this:
repo/
├─ generated-lastest/
│ ├─ src/
│ ├─ functions.php
├─ generated-7.4/
│ ├─ src/
│ ├─ functions.php
And then the autoload config in composer would reference a single entrypoint file that would redirect us to the correct folder depending on the php version?
to be loaded depending of the php version of the client
That is done by keeping one git branch for each PHP version. At least many other packages do it this way.
I am not sure I understand the link with rector
That Rector issue is about automatically combining many .php files into one functions.php
.