Hướng dẫn cài đặt Drush sử dụng Composer trên Mac OS X 10.9 Mavericks

Hướng dẫn cài đặt Drush sử dụng Composer trên Mac OS X 10.9 Mavericks

Following on from our previous guide “Creating and using an public/private SSH key-pair in Mac OS X 10.9 Mavericks” in which we walked you through the process of setting up Git on Max OS X 10.9 Mavericks, we’re now going to look at installing Drush using Composer.

If you’re never heard of Drush before, the description provided on the  Drush GitHub repository offers a succinct and accurate explanation of what Drush is and the tools it makes available to you:

Drush is a command line shell and Unix scripting interface for Drupal. If you are unfamiliar with shell scripting, reviewing the documentation for your shell (e.g. man bash) or reading an online tutorial (e.g. search for "bash tutorial") will help you get the most out of Drush.

Drush core ships with lots of useful commands for interacting with code like modules/themes/profiles. Similarly, it runs update.php, executes sql queries and DB migrations, and misc utilities like run cron or clear cache.

Ultimately our goal in these series of guides is to give anyone both experienced and inexperienced alike the knowledge and skills required to configure their system so that an installation of Drupal can be run from it with a suite of tools available for them to use from the get-go.

Let’s begin.

Installing Composer

Rather than installing Drush manually, we’re going to let a tool called Composer do all the hard work for us. Composer is a tool for handing dependency management the full description for which can be found on the Composer site. In a nutshell though, the following sums up Composer well:

Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.

Let’s install Composer. Open a new instance of the Terminal by either navigating to the Applications folder within the finder followed by the Utilities sub-folder, or alternatively by pressing “Cmd+Space” and typing “Terminal” followed by the “Enter” key.

Once open, type the following command to ensure you’re in your home directory:

cd ~/

To download composer, type the following command into the Terminal and hit enter:

curl -sS https://getcomposer.org/installer| php

At this point you could type “~/composer.phar --help” into the command line and you’ll most likely get a list Composer help documentation, but we want to be able to access Composer simply by typing the command “composer”, so let’s move the *.phar file into our “/user/local/bin” directory.

Note: On a fresh installation of OS X 10.9, the “/usr” directory will very likely be empty. If this is the case, to enable us to successfully move Composer to “/usr/local/bin/composer” you’ll need to type the following two commands“sudo mkdir /usr/local” and “sudo mkdir /user/local/bin”. After typing the first command, you may be prompted for your system password. Simply enter it to continue.

Now we’re all set to move Composer. To do this, type the following command into the Terminal:

mv composer.phar /usr/local/bin/composer

Note: If you get an error trying to move the file, prefix the command above with “sudo” and try again.

We should now be able to type “composer” into the terminal and get something other than an error returned. Try this out by typing “composer”and hitting enter.

Adding the Composer “bin” directory to our path

Once Drush is installed, we will be able to type“~/.composer/vendor/bin/drush” followed by the Drush command of our choice, but who wants to do that every time? 

To be enable the ability to type “drush” followed by our command we need to add Composer’s bin directory to our path.

In your home directory “~/“ type the command “nano ~/.bash_profile”and add the following line to the file that opens up:

export PATH="$HOME/.composer/vendor/bin:$PATH"

Quit Nano, by pressing “Ctrl+X” and when asked if you wish to save the document type “Y” and hit “Enter”.

Finally we need to re-source our “.bash_profile” file by typing “source ~/.bash_profile” into the Terminal (alternatively you can quit and re-open the Terminal).

Installing Drush

At this point, installing Drush is a piece of cake. Simply type the following into the Terminal and hit “Enter”

composer global require drush/drush:dev-master

Drush should now be installed. To ensure it is, type “drush” into the command line and you should see a series of Drush help documentation.

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Drupal 8 Now: Sử dụng Composer dependencies trong Drupal 7

Drupal 8 Now: Sử dụng Composer dependencies trong Drupal 7

Using namespaces and the PSR-0/4 standard creates a clean and simple way of sharing code across projects. This is a core part of the Drupal 8 architecture.

How do I write a "professional" blog?

How do I write a "professional" blog?

Web logs or blogs started as a way to talk about new technologies, vent about life and interact in a no-holds-barred forum. Since blogs became the next big thing, an increasing number of companies have come to see them as the next great public relations vehicle a way for executives to demonstrate their casual, interactive side.

6 Drupal SEO Modules Required for Superior Search Ranking Performance

6 Drupal SEO Modules cần thiết cho hiệu suất xếp hạng website

If you are running your site with Drupal, you are reaping the numerous benefits this publishing platform has to offer.

Công ty diệt chuột T&C

 

Diet con trung