Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New, autoloader-centric file structure #348

Open
szepeviktor opened this issue Apr 25, 2022 · 5 comments
Open

New, autoloader-centric file structure #348

szepeviktor opened this issue Apr 25, 2022 · 5 comments

Comments

@szepeviktor
Copy link
Contributor

szepeviktor commented Apr 25, 2022

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?

@szepeviktor
Copy link
Contributor Author

@Kharhamel I understand it may hurt your feelings.

@szepeviktor
Copy link
Contributor Author

Asked how to do it: rectorphp/rector#7131

@Kharhamel
Copy link
Collaborator

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?

@szepeviktor
Copy link
Contributor Author

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.

@szepeviktor
Copy link
Contributor Author

szepeviktor commented Apr 26, 2022

I am not sure I understand the link with rector

That Rector issue is about automatically combining many .php files into one functions.php.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants