Watch videos with subtitles in your language, upload your videos, create your own subtitles! Click here to learn more on "how to Dotsub"

Using Composer and Git to Download Files

0 (0 Likes / 0 Dislikes)
Using Composer and Git to Download Files with Joe Shindelar In this tutorial, we’re going to look at how to use Composer and Git to manage files in the core software and add-on modules or themes. By the end of this tutorial, you’ll know how to use Composer and/or Git to download files and dependencies in the core software, or add-on modules and themes from drupal.org. Before you get started with this tutorial, you'll want to make sure that you have Git and Composer installed. And it's probably a good idea to test this on a development version of your site first. See the written version of this tutorial for links to each of these prerequisite tutorials. If you’re unable to install the Git or Composer tools on your live server after following the steps in any of the sections below on your local server, you’ll need to transfer any updated or added files to the live server. The recommended procedure is to make an archive or a zip file of the new and changed files, and then transfer that archive to your live server and extract it there. If you’re using Composer, you also need to make sure that you check for updates and additions to the following files in the root of your installation, as you’ll likely need to keep those additions in place: the vendor directory and the autoload.php, composer.json, and composer.lock files. Follow this set of steps if you want to download the development version of the core software or the contributed module or theme from the project’s Git version control system. This is useful if you want to make changes or contribute patches to the project. In a command line window, change to one level above the directory where you want to create the files. In the core software, this would be your webroot. For an add-on module, this would be the module’s directory or a subdirectory like contrib under the module’s directory. Next, locate the page for the project that you want to download on drupal.org. Whether you’re downloading Drupal Core or any contributed module or a theme, you should be able to locate the Version control tab. Click on this. This will open a page giving you Git commands for this specific project. You can copy the Git clone command from the options here under Setting up a repository for the first time. Then back in your terminal, you can paste and run this command. This will create a new directory named with the short name of the project, drupal in this example, and then clone the required files into that directory. If necessary, you can rename the directory at this time. If you downloaded the Drupal project, continue with the next set of instructions to download its external dependencies using Composer. Note that if you downloaded the drupal project from the .zip or TAR archive links on drupal.org, these dependencies are already included for you, and you don’t need to do this. Change directories so that you’re in the core software’s root directory. For me, that’s the drupal directory. And then from there, run the command, composer install. This is going to download all of the required external dependencies that were not part of the Git repository that you just cloned. You should now be ready to install Drupal core. Follow this set of steps if you’ve not yet downloaded or installed the core software, and you want to use Composer to download both the core software and all of its external dependencies. At the command line, change to one level above the directory where you want the software to reside, and then enter the command, composer create-project drupal/drupal, and then the word drupal again. This will download the core software and all of its external dependencies into a directory named drupal. You can change this last instance of the word drupal to whatever you want the directory for your project to be named. After running this command, you’ll have downloaded all of the core software and its external dependencies, and you can now go ahead and start installing Drupal. Follow this set of steps if you’ve already downloaded the core software and you want to use Composer to add a contributed module or theme. Each time you want to add a contributed module or theme, determine the project’s short name. This is the last part of the URL of the project page. For example, if I want to install the Geofield module, the short name in this case is geofield, the part at the end of drupal.org/project/geofield. At the command line, I can enter the command, composer require drupal/geofield. Substitute geofield for the name of whatever module or theme it is that you are trying to install, and then hit Enter to run the command. Doing this will download the module or theme that you are trying to install and any of its external dependencies, if there are any. You can now go ahead and install the module or theme. Follow this set of steps if you want to update the files for the core software or a contributed module or theme after having already started to manage dependencies for your project using Composer. First thing you need to do is determine the short name of the project you want to update, just like we did earlier. In this case, we’re talking about the Geofield module. Then, you need to determine how to enter the version number you want to update to. For example, for version 8.X-1.7 of a contributed module, you would enter just the 1.7. And, for the core software version 8.3.1, you would enter just 3.1. In this case, if I wanted to update to the Geofield 1.7 version, I would enter the command, composer require drupal/geofield:1.7 and then hit Enter. This would update the module to that version, the module from drupal.org. In this tutorial, we learned how to download and update both core and contributed modules or themes using either Git or Composer.

Video Details

Duration: 6 minutes and 1 second
Country: United States
Language: English
License: All rights reserved
Genre: None
Views: 4
Posted by: drupalizeme on Feb 1, 2018

Using Composer and Git to Download Files

Caption and Translate

    Sign In/Register for Dotsub to translate this video.