Guest User

Untitled

a guest
Mar 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. This is how you create a composer.json that places itself inside the (managed) vendor directory
  2. Very simple, but I didn't find an example while searching, and I want to remind myself that I can do this.
  3.  
  4. Place this file inside the vendor directory.
  5. The following would be an example project structure
  6.  
  7. ```
  8. +- /project
  9. +- /lib
  10. +- /TestNamespace
  11. - TestClass.php
  12. +- /vendor
  13. - composer.json
  14. - composer.lock
  15. +- /bugsnag
  16. +- /composer
  17. +- /psr
  18. ```
  19.  
  20.  
  21. ```
  22. // This is not a valid composer file, because it is not valid JSON due to the comments.
  23. {
  24. // This is the important part
  25. // vendor-dir is the package install path, typically 'vendor'
  26. // Setting it to "." changes the composer package install path relative
  27. // to composer.json, but does NOT change the install structure.
  28. "config": {
  29. "vendor-dir": "."
  30. },
  31. "require": {
  32. "php": ">=5.4",
  33. "bugsnag/bugsnag": "^3.0",
  34. "psr/log": "^1.0",
  35. },
  36. // The other component. The PSR-4 namespace is simply loaded relative to the vendor-dir
  37. "autoload": {
  38. "psr-4": {
  39. "TestNamespace\\": "../lib/TestNamespace"
  40. }
  41. }
  42. }
  43. ```
Add Comment
Please, Sign In to add comment