PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, November 10, 2022

[FIXED] How to find the base directory where vendor is installed from a composer package

 November 10, 2022     composer-php, php     No comments   

Issue

I'm trying to find the base directory of my application from within a composer package. Is there an composer API or proper way to accomplish this.

To clarify, if my package install looks like this and I've got files here (using psr-4):

/home/project/vendor/Acme/my-package/src/

how can I find /home/project dynamically?

Updated Info:

I'm trying to load a .env file from the root which contains an API URL endpoint via Dotenv package from within the package.


Solution

Based in input from @Sven best and cleanest solution was to collect input on class initialization and leave configuration out of the package.



Answered By - dcbarans
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing