0

I would like to integrate Composer into some web projects. Because I cannot assume that someone has access to anything above /www or /htdocs, my idea is to provide a composer.phar with the web project and trigger the updater with a cronjob, so that I don't have anything to do for the update on my project.

The problem is, to have the ability to trigger the composer it will need the path to the php.exe and it's not guaranteed that the environment variable is set to Linux servers.

Is there way to get Composer work on web servers without access to php.ini and without knowing the path to the php-programm?

user3292653
  • 602
  • 1
  • 7
  • 25
  • Maybe this is a stupid question, but did you already try it? If so, what was the error? I would expect that, since the PATH will include the path to PHP, that `composer update` should not give a problem, but this could be my optimistic nature. – Dirk McQuickly May 07 '14 at 14:47
  • That is true, but I'm searching a solution that always works. If I build a script that other users can use, it's important that I can assure that the composer works everytime. It should not be bound to the installation path of PHP or if the PATH to the php.exe is set. The question of this thread is how?! – user3292653 May 07 '14 at 15:01
  • 1
    You refer to 'php.exe' (Windows only) but also mention Linux. Which are you working with? – halfer May 07 '14 at 16:11
  • Sorry, I was still in thoughts on my test on Windows (locally), but my target is Linux so forget about the .exe extension. – user3292653 May 07 '14 at 17:54
  • Again, I'm seraching a solution that you can integrate the composer inside a web project also if you don't know the php-programm-path or can't modify the php.ini. – user3292653 May 07 '14 at 18:01
  • possible duplicate of [Run composer with a PHP script in browser](http://stackoverflow.com/questions/17219436/run-composer-with-a-php-script-in-browser) Also, this is a really stupid idea. It's much better to do the Composer'ing offline, and then the whole project with the vendors dir to a server, rather than trying to run Composer in an environment you don't completely control. – Danack May 08 '14 at 10:52

1 Answers1

1

The composer.phar file is supposed to work out of the box when getting executable flags for the user it is trying to run, i.e. /path/to/composer.phar will work without adding PHP. On Windows, .phar files probably should get associated with the installed PHP version when being opened.

But one important thing: Composer does nothing related to ensuring uninterrupted production service! That's not it's task. Always think about what happens if anything that Composer is doing fails. There are so many components that might become unavailable, starting with packagist.org, Github/Bitbucket/younameit, accidentially grabbing broken released versions during update which will disable the update process entirely, and so on...

Think about the risks you add when trying to add such attention-free cron-based update step.

Another thing is that you have to ensure that the tools needed to get the software onto the machine are installed. This means you must have at least ZIP tools available, tar/gz as well, and depending on whether you install branches (you should not do this, even more so with automated unattended updates) you will need Git, Mercurial and SVN installed on the production machine (and this might also be true if you only install tagged versions). So there isn't just the dependency to PHP, but to at least these five tools, too.

Sven
  • 69,403
  • 10
  • 107
  • 109
  • You're right, I forgot about that. Composer does not catch errors? In my opinion, that should ble also a task. I would like to rely on it and if there are errors get a error message. So there is otherwise no possibility that we may lose sight of? – user3292653 May 09 '14 at 06:17
  • I wouldn't count on Composer not changing stuff when trying to update. You might end up having an unstable vendor directory tree due to a random, but rare problem - like "out of file space error" in the middle of the unzipping. Remember that Composer is only in it's alpha state, it isn't released yet in a final, stable version. – Sven May 12 '14 at 01:03