نصب Composer و Drush 8 برای کار روی Drupal 8

Installing Drush on Windows with Composer

Acquia Dev Desktop comes with Drush pre-installed. So, if you’re using that, you already have Drush on your machine, and you’re ready to begin the series. If you’re using another AMP stack, such as WAMP, in this case, you'll need to install Composer to get the latest release of Drush.

While you can install Drush to be used with the default command prompt, if you take a look at the Install page on drush.org, you'll see the disclaimer that says Windows support is still lagging, and lower on the page, that while most Drush commands will run in a Windows CMD shell, the Git Bash shell provided by Git for Windows is preferred. This video will show you how to install Drush on a Windows machine to be used with Git for Windows. (Click here for a video on installing Git for Windows)

The process to install Drush 7.0.0 and up is in some ways more complicated than previous versions, it is also much simpler for other reasons. For example, you have to install Composer first, in order to install Drush, but Composer is required for Drupal 8 (so you might need to install it eventually anyway) and once Composer is installed, installing Drush is just a single command in the command line.

Install Composer for Windows

Let's start out by install Composer for Windows.

  • Go to getcomposer.org/download
  • Scroll down and click on "Composer-Setup.exe"
  • Save the file, or just click "Run"
  • Click "Next"
  • Click "Next"

Now, we need to tell Composer where php is installed. This will be different based on whether you're using Wamp, Xampp, etc. I have Wamp installed so mine is at: C:\wamp\bin\php\php5.5.12\php.exe

  • Browse to C:\wamp\bin\php\php5.5.12\php.exe
  • Click "Next"
  • Click "Install"
  • Click "Next"
  • Click "Finish"

Now, when I open a Git bash, and type "composer --version" and press Enter, we'll see that I have version 1.0-dev installed!

اگر هنگام نصب composer با خطای SSL مواجه شدید: http://www.codecheese.com/2015/02/installing-composer-xampp-windows/#div...

Install Drush via Composer

Now, we're ready to install Drush with composer. It's pretty simple. In fact, it's a single line in the command line.

  • In the Git Bash, type "composer global require drush/drush:8.*" and press Enter.

This will install Drush to "C:/Users/[user name]/AppData/Roaming/Composer/vendor/drush/drush"

We can't run it from anywhere else though, so we need to add that path to our Environment Variables.

Adding Our Drush Folder to the System Path

To add a directory to the PATH, we need to edit the PATH System Variable

  • Open the Control Panel
  • Change the "View by" option to "Small icons"
  • Click "System"
  • Click "Advanced system settings"
  • Click "Environment Variables"

There are two sections here. One for "User variables" and one for "System variables". The first only affect the logged-in user, while the second affect all users on the system. I'm going to change the User variable because it's safer, but if you have a reason to change the system variable, do that instead.

I don't have a Path User Variable, so I'll create one.

  • In the "User variables" section click "New"
  • Variable name: "Path"
  • Variable value: "C:/Users/Modules/AppData/Roaming/Composer/vendor/drush/drush" (Replace "Modules" with your user name)
  • Click "OK"

Note:
If you do want to add this path to the System variables instead:

* In the "System variables" section scroll down and click on "Path"
* Click Edit (Each location is separated by a semicolon (;).)
* Scroll to the end of the line, add a semicolon, and paste the path there

You would also follow these steps in the User variable section, if there were already a "Path" variable present.

  • Click "OK"
  • Click "OK"

If we try to type "drush" and press Enter in the command prompt, it still won't work becuase it's already loaded the previous PATH value. We need to close this window and open a new one to load the new PATH.

  • Click the red "X"
  • Open a new Git Bash window
  • Type "drush" and press Enter

This time, we see all of the available Drush commands. And if we type "drush status" and press Enter, we'll see that we are running version 7.0.0.

برچسب ها: 

افزودن نظر جدید