Changing PHP's directory when working with Git

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jateeq
Forum Newbie
Posts: 14
Joined: Mon Mar 01, 2010 12:16 pm

Changing PHP's directory when working with Git

Post by jateeq »

Hello,

I am working in conjuction with PHP and Git. To get things done, i am exectuting shell commands using php's shell_exec and exec functions, but I keep on having to change the directory to where I need the command to be run (only for working trees). Once the directory is changed, in some places where I am using the require() function to include files local to the source code folder, I get a message that no file exists, since I am no longer in the source code's directory. I could change the directory back to where it should point to, but I figure this isn't the best way of going about this, and requires a lot of manual work. Any ideas on how to keep the current directory path consistent, while simultaneously being running shell commands in other directories? Or is changing directories on an as needed basis the best way to do this?

Fanks,
Jawad.
Post Reply