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

Autoloading issue: PSR-0 vs PSR-4 #178

Open
live627 opened this issue Feb 11, 2023 · 2 comments
Open

Autoloading issue: PSR-0 vs PSR-4 #178

live627 opened this issue Feb 11, 2023 · 2 comments

Comments

@live627
Copy link

live627 commented Feb 11, 2023

Difference between psr-0 and psr-4

PSR-4 is something like 'relative path', PSR-0, 'absolute path'.

psr-0

Looking at vendor/composer/autoload_namespaces.php file you can see the namespaces and the directories that they are mapped to.

composer.json

"autoload": {
        "psr-0": {
            "Liquid\\": "src/"
        }
} 
  • Looking for Liquid\Template in src/Liquid/Template.php

psr-4

Looking at vendor/composer/autoload_psr4.php file you can see the namespaces and the directories that they are mapped to.

composer.json

"autoload": {
    "psr-4": {
        "Liquid\\": "src/"
    }
}   
  • Looking for Liquid\Template in src/Template.php

composer.json

"autoload": {
    "psr-4": {
        "Liquid\\": "src/Liquid/"
    }
}    
  • Looking for Liquid\Template in src/Liquid/Template.php

How to fix

Either

  • Move both sources and tests up one level
  • Change autoloader to specify psr-0
@sanmai
Copy link
Collaborator

sanmai commented Feb 11, 2023

Looking for Liquid\Template in src/Liquid/Template.php

Isn't this is what we have in actuality?

@live627
Copy link
Author

live627 commented Feb 11, 2023

So, there is no bug, really, but an issue with not following the spec exactly.

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