I want Drush 9 on a Drupal 8 production server without having to install Composer. Is there any way to do this?

And if that is not possible, can anyone suggest an alternative to Drush especially for maintenance, updating and syncing the site with dev and staging?

  • Why not install composer? You can install composer in a project independent way, e.g. inside a drush-specific directory, and that would allow you to not only have drush 9 but also run future updates on it without workarounds. – Stefanos Petrakis May 7 at 8:18
  • To be blunt, and ignoring other issues, composer is a ridiculous resource hog. I have some very small D8 sites I want to put on a server or two and be able to ssh in and run the odd drush command. I do not need, nor do I want, the overhead of composer. As the servers and sites are small I am likely to have issues even using composer without running out of memory. I will have very few dependencies to worry about and I am the only person working on the site. – tanbog May 7 at 11:56
  • Just as a side not, yes composer can be a hog when doing dependency resolution and picking a set of compatible versions. If you have a lockfile, though, and just do a composer install, the overhead is a lot smaller since it just installs what is in the lockfile. – mpdonadio May 7 at 14:27
  • Not to mention that if you're looking for a way to break your environment, Composer is perfect way to ruin your day. One little mistake, and your environment becomes smoking rubble – sea26.2 Nov 10 at 22:09

If you don't want composer in production on your server, you can run the composer commands locally to install Drush, then make sure to push the vendordirectory to the server. Make sure to also commit the composer.json and composer.lock files, so that anyone else working with the codebase can handle composer on their own local machines as well.

In this way you never need composer on the remote production server, but can get drush.

  • If I push the vendor directory. Do I need to take further steps to then use drush on the server? So, for example, I have several sites on the server and want to use Drush to manage them globally via aliases. I am guessing this wont work out of the box with only a vendor directory for each site? – tanbog May 7 at 7:58
  • Ideally you should install Drush Launcher (docs.drush.org/en/master/install), but that said, Drush will exist at vender/drush/drush/drush, so you can use it without Drush Launcher if there is some reason why you are not able to install that. – Jaypan May 7 at 8:01
  • Is there any point to everything else in the vendor folder then? Shouldn't I delete or gitignore the rest of that folder since there will be no composer on the server? – tanbog May 7 at 12:11
  • 1
    Anything in your vendor file will be required. If you aren't using Composer on your server, you need to be doing it locally, and then pushing to the server. The files in the vendor folder will be required. – Jaypan May 7 at 12:28
  • 2
    The vendor directory is set to be ignored in the .gitignore file. It sounds like you need to fix that. – Jaypan May 11 at 5:47

On the production stage we don't need Composer (neither composer.json nor composer.lock), Composer is used to build your project and to generate the vendors after that it is necessary to pack all the generated files and to deploy them on the target server.

  • How do I get Drush on the production server without composer being present? Sorry if this seems like a silly question but the composer and drush guides out there are super confusing on this. – tanbog May 7 at 7:56
  • Drush is present in your vendors directory that will be deployed in your server, so all you have to do is settings the path to drush /vendors/drush/drush. – tijani nasser May 7 at 13:10
  • how exactly do you "pack" the vendors folder? – tanbog May 7 at 13:30
  • You can use maven or phing to package your web site and then put it in the server. – tijani nasser May 18 at 11:54

If you build out your D8 site locally in your dev environment using Composer, you'll have Drush 9. Then, if you commit your D8 instance (Git) and pull onto your server, you'll have Drush- albeit you'll have to execute using the full path. For example: From my command line on a Ubuntu 18.04, I can execute

$ vendor/bin/drush pml --no-core

My D8 instance on the Production servers contains the following at the root.

enter image description here

Notice that /vendor is committed and present in this repository. And that contains /vendor/bin/drush

Refer to the Drush Documentation for more info.

Hope this helps!

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.