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

Creating a directory after installation finishes #1417

Closed
p opened this issue Dec 13, 2012 · 4 comments
Closed

Creating a directory after installation finishes #1417

p opened this issue Dec 13, 2012 · 4 comments

Comments

@p
Copy link

p commented Dec 13, 2012

Maybe you can help us out here.

We have a directory that is not used by phpbb itself, and is not in the repository as a result, that users (most of them in fact) are expected to use. Therefore we want to make sure our users have this directory when they look for it.

Solution #1: we build release packages, and can trivially create the needed directory there. This works for most users. Problem is, anyone cloning the repository won't have the directory in the git checkout.

Solution #2: since we require users to install dependencies via composer for any git checkout, we thought we could ask composer to create the directory for us when it's done installing dependencies.

Therefore, we have: https://github.com/phpbb/phpbb3/pull/1032/files

Now, the problem with this is mkdir fails when the directory exists. mkdir -p apparently does not exist on windows so that's a no go.

Any suggestions, short of writing a php script to create the directory?

If we do write a php script, do we have to specify php binary name ("php", on PATH) in the command? Can composer execute the script with whichever php was used to execute composer?

@stof
Copy link
Contributor

stof commented Dec 13, 2012

the composer scripts can also be a PHP static method (it was even the only way originally). So it would be "post-install-cmd": "phpbb\util::createFolder" or something like that.

Btw, take care that scripts only work in the root package (but I guess phpbb is not really expected to be installed as a dependency of another project anyway)

@Seldaek
Copy link
Member

Seldaek commented Dec 13, 2012

What stof said is an option yes. Because indeed shell scripts are pretty hard to manage cross-platform. The other option is to just add a .gitkeep in that dir in the git repo and be done with it.

@p
Copy link
Author

p commented Dec 17, 2012

Thanks, one question though:

phpbb\util::createFolder - does that function have to be in a particular file? While phpbb uses autoloading for some of its parts we set it up ourselves.

I forget why we don't (want to) have it as a .gitkeep. I would guess someone was opposed to it, maybe on the basis of having too many empty directories in the repo. If it was up to me I'd have a Makefile create the dirs I needed.

@stof
Copy link
Contributor

stof commented Dec 17, 2012

@p it needs to be autoloaded through composer's PSR-0 autoloader (so that composer can autoload it when running git)

@Seldaek Seldaek closed this as completed Jan 1, 2014
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

3 participants