Drupal 7 Installation Profiles

By shane
Fri, 2013-03-01 23:51
Daily Dose of Drupal Episode #118

Share with Others

You may have heard of a Drupal installation profile but are not sure what a Drupal installation profile is or how you can write your own Drupal installation profile. This video will walk you through Drupal 7 installation profile basics, and also show you some examples of how installation profiles are developed. This episode is meant to be a getting started guide for those developers or site builders that want to get a basic grasp on Drupal installation profiles and how they can be used to build flexible and dynamic Drupal distributions.

Thanks to Drupalize.me for sponsoring this episode of the Daily Dose of Drupal.

Hello everyone and welcome to another Daily Dose of Drupal, today we’re on episode number 118. And today we’re going to be going over the basics of an Installation Profile. What is an Installation Profile? How do you use it and how do you write one of your own if you need to? Before we get started; as always I am Shane Thomas, you can follow me on Twitter at smthomas3, you can also go to codekarate.com and sign up for the newsletter over here on the left.

Today’s episode is sponsored by drupalize.me. If you’re looking to learn more about Drupal you need to check out drupalize.me. They have tons of videos from the very basics to some of the most advance Drupal topics you’ll ever need to learn about. Go ahead and check them out, use the coupon code CK20FEB for 20 % off.

Let’s go ahead and get started; so what exactly is a Drupal Installation Profile? Well I pulled up a drupal.org site right here, its node 306267 and it talks about how to use an installation profile, it also talks about what is an installation profile. I’m not going to go over every piece that it says here but I’m just going to give a quick summary. Basically every Drupal site that you built it has an installation profile that’s selected when you installed the site.

Each site only has one installation profile, it’s selected when the site is originally installed so if you already have a site that’s up and running well it has the installation profile that it has. So whatever you selected when you install to the Installation Profile that it comes with or that is currently using there’s really no way to change an installation profile easily, you could of course if you want to get to the database and do some other things but for the most part, once you have installed the site it has an installation profile I already built into it.

All installation profile is it seems really complicated; all it is is just for the most part is a collection of modules your Drupal website is going to be installed with. You can also do things during an Installation Profile when this site is being installed such as install various or set up various blocks installed or add various content to other set up tasks so that once the system or the site is done building or installing it has a pre-package and content and block settings and all this types of stocks.

So first thing to realize is it’s not all that complicated, there’s really installation profiles at its core are very simple, just a way to basically package up a reusable modules and configuration and themes and reuse them on a new fresh installation. So examples of different distributions on Drupal if you go to drupal.org/project/distributions you can see a bunch of examples.

Commerce Kick Start if the first one up here. Basically the quickest way to get up and running with Drupal Commerce so it basically out of the box if you install this installation profile before you install you’re Drupal site and you select Commerce Kick Start as the installation profile. It’s going to give you a whole bunch of Drupal Commerce related modules, a whole bunch of setups so out of the box when you start … you almost have a completely working Drupal Commerce store for selling products online. Open Publish is another one, it’s more of a distribution for online news industries, Open Public is for government and public policy organizations, Drupal Commerce or commence is for community based websites.

And so all these things are as you can see there are pre-package set that comes with Drupal core plus it comes with the setup modules and themes and configuration for making this specific type sites. Just saves you from having to download all the modules manually, install them, add content or configurations, you know, download the themes so it’s really a simple way to get up and running. There’s another page on drupal.org for how to write a Drupal 7 Installation Profile. Installation Profiles are similar to modules, there’s an info file, a .install file and a .profile file.

So this is node 1022020 on drupal.org and it talks all about how to write a Drupal Installation Profile. Let’s go ahead and take a look at some Installation Profiles that come with Drupal 7. The first thing I’m going to do is I’m going to show you that this is just a basic Drupal 7 site, it has the site’s directory, you can go to the site’s All Folder and download Modules Themes but the important thing is there’s this Profiles Directory.

Inside this Profiles Directory there are currently four installation profiles. Three of this that come with standard Drupal; minimal, standard and testing. Commerce Kick Start is one that I’ve downloaded and dropped in here so we can look at that as well. So the first one we’re going to look at is the Minimal Installation Profile. Minimal Installation Profile simply installs a smaller amount of modules than the standard and has a little bit less setup.

So if you can get started without having all the extra Drupal Core modules installed so let’s go ahead and take a look; this is the minimal .info file so here’s the info file of this Installation Profile, this is one that comes with core as I mentioned before and it says it starts with only few modules enabled.

The few modules are Dependent or Block and DB Log, so those dependencies, those are automatically going to be enabled when you select this installation profile when you go through the process of installing this Drupal site. If we go into the minimal.install file you’ll see it implements hook_install and this is use to enable some of the standard blocks.

So you can see it gets the default theme, it enables some of the different blocks here, the content block, the main content block, the login block navigation and management block for the Help section and so this is simply just dropping blocks in when you select this Installation Profiles so when you start you have a couple of blocks already dropped into the default regions in the Bartik Theme.

And then in the minimal.profile there’s really not much here, the only thing is this one line which you’ll see in a lot of profile or .profile modules, it’s just a simple line that sets the site name with whatever the server name is so it doesn’t start with a blank site name.

So you’ll notice if I go to the standard profile it’s exactly the same besides the fact that it’s using standard because that’s the name of the profile instead of minimal. We can look at the standard .info file, you can see there’s much more dependencies here. This means any modules in this list are going to get turned on when you install a standard profile Drupal 7 site so you can see there’s things like I already have in the toolbar and the overlay where on the minimal.info you’ll notice there is just not as many modules there. If we take a look at this standard.install you can tell that there’s much more here that goes on when you install a standard Drupal 7 installation profile or Drupal 7 site with the standard installation profile, still goes through hook install and it adds some text formats, you can see it enables some standard blocks, it creates your basic node types so if you use standard profile you’ll get page and an article content type out of the box and the reason I’m going through this is if you’re writing your own installation profile some of the stuff that is in the standard installation profile or minimal installation profile can be basically drop into your own installation profile and just reuse and modified based on your needs so you don’t really have to rewrite the wheel and at the end here I’m going to show you a couple tools that you can use if you want to build your own in a little bit simpler way.

So the last one we’re going to take a look at and what you’ll notice that so far all these are pretty similar … just a standard one and it has a few more options of course so we’re going to take a look at Commerce Kick Start which is not a core installation profile but it’s one that you can download on drupal.org. You’ll see here there’s a lot more files inside here, there’s a Themes folder, Script folder, Modules folder and a Libraries folder.

So also these .make files which I’m probably going to be covering tomorrow how to write .make file to download your different modules and themes for your installation profile or your platform but you’ll notice that there’s still a .profile and there’s still a .install and a .info. I’m going to open those up and I want to come back in and I want to cover up what some of these other things are as well. So I’ll open these three files and you’ll notice the commerce kick start.info you can see this info file is much larger. A lot of the distributions in drupal.org are going to have larger info files because they have to install a lot more modules, a lot more themes when the sites are actually built or installed.

So as you can see they install the core modules first then they install commerce dependencies so these are modules that Drupal Commerce needs to run then installs all the various commerce modules so all these are dependencies, various commerce services, other contributed modules, features, migrates, search API and other distribution related modules for Commerce Kick Start. So as you can see that list is much larger, the Install file is also much larger.

We’re not going to go through all of it because as you can see almost a thousand lines on of code but it is similar to any of these other install file except for the fact the it does a lot more when you install a Commerce Kick Start site. It has to because it sets up almost a completely functioning Drupal Commerce store.

So you can take a look at that, it’s relatively well documented and commented so you can read the comments and find out what it’s doing, you can also look at this .profile for Commerce Kick Start. Here it implements default image style, also has a Hook Form Alter similar to the other ones but it sets more values, it does a hook system info alter and just a bunch more of other things. Hook Update Projects Alter, Hook Update … you can look all these up on drupal.org and see what they’re doing.

Like I said this is well documented, you can follow along and find out what this .profile is actually doing once it’s installed make sure to read on how to write Drupal 7 installation profile as that talks to what can go inside an install file and what can go on the .profile file. Before we stop here today I’m also going to cover … inside the .info file for Commerce Kick Start there’s a lot of dependencies that aren’t in standard Drupal and you might be wondering how is it going to install the Rules module if the Rules module isn’t in my sites All Modules directory or how is it going to install the Views Module.

Well inside this Distribution or Installation Profile there’s a Module and Themes Directory. Inside this Themes you can see there’s a Commerce Kick Start Theme, Omega Kick Start and Shinny, all these are just various themes and once you get inside the modules you’ll see there’s contributed modules such as your Views and your Rules. And so Drupal knows since you’re using this installation profile to look here for modules and themes.

So any themes that you need can be dropped into your Installation Profile and you can use dependencies from these themes or modules to install when you actually are installing a Drupal Site so for instance Cloud Zoom is an option in here which means I can add a dependency to my .info file for Cloud Zoom meaning that when I install this Drupal 7 site Cloud Zoom is going to be enabled if it’s in that dependencies list.
One important thing to note when you’re building a .info file for installation profile make sure to … if there are any dependencies that come first such as Rules or Views in the case of Commerce Kick Start you want those to show up above the modules that depend on the.

So Rules is an example, it shows up before a lot of the commerce modules that’s going to require rules. Just something to keep in mind there and the last thing we’re going to cover real quick before we finish up is on druapl.org there’s project/profiler, it’s this profiler project it’s actually not a module, it’s just a library for writing installation profiles, you can take a look at some of the links here and learn about what this does.
There’s also a Profile Builder which is an extension of the Profiler Installation Profile Simplifier and it creates downloadable package that gives you well-made installation profile and just make file based on the site it’s installed on. So you basically, it sounds you can turn this on, you’re able to download basically a pre-built installation profile based on your Drupal site so if you already have a Drupal site built and you want to deploy other sites like it or you want other people to be able to build sites like yours, you can use tool and it’ll help you get started, I don’t know all the ins and outs of it, I haven’t used it, I always build mine manually but this is a tool here for you to use and take a look at and see if it helps you out.

So that’s all we’re going to talk about today on learning more about Drupal Installation profiles. As I said before there’s nothing really complicated about them. Some of them look a little intimidating when you look at how many lines of codes there but if you think about it in a simplest form it’s just a way for you as a user to install the Drupal 7 site and get a set of modules, themes and other types of configuration right out of the box so instead of getting standard Drupal you’re getting setup for a Drupal Commerce site with a bunch of bells and whistles with modules and themes already there or you’re getting a system for publishers in the case of Open Publish.

So go ahead and look at these other distributions on Drupal, there’s 573 listed here, you maybe be able to find some that you can use in the future for future Drupal sites rather than starting from scratch and use those to get a jump start on your Drupal development. Thanks again to drupalize.me for sponsoring this episode and thank you for watching the Daily Dose of Drupal. Well see you next time.