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

Changed to PSR-4 autoloading #70

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
/composer.lock
/phpunit.xml
/earl-report.jsonld
/.idea
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be in your global .gitignore but not committed in the repository.

6 changes: 4 additions & 2 deletions composer.json
Expand Up @@ -22,7 +22,9 @@
"json-ld/tests": "@dev"
},
"autoload": {
"psr-0": { "ML\\JsonLD": "" }
"psr-4": { "ML\\JsonLD\\": "src/" }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be way easier to just change the line above to "psr-4": { "ML\\JsonLD\\": "" } and leave the rest as is. I'm not a big fan of hiding everything in a src directory. Also, please make sure the tests pass.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without it, on a production server the Tests are also autoloaded. Because the tests folder is also included in the primary source.
This is quite a bit of overhead. I always use an autoload for the source, and an autoload-dev for the tests. That is the reason for the src folder being separated from the tests folder.

I'm not really sure why the tests fail. But let me check that out.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean they are autoloaded? They are just loaded if they are used. Or do you mean that the class map grows? Can't that be worked around with exclude-from-classmap?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"exclude-from-classmap": ["/Test/"]

should work.

See "Excluding paths from the optimized classmap" section of https://seld.be/notes/new-composer-patterns

},
"target-dir": "ML/JsonLD"
"autoload-dev": {
"psr-4": { "ML\\JsonLD\\Test\\": "Test/" }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be in a directory called tests/ to match the popular structure of most PHP libraries.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing. And what about the namespace of the tests?

}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.