Build site
This commit is contained in:
parent
6f8d067847
commit
0c7de8559a
743 changed files with 92961 additions and 0 deletions
|
@ -0,0 +1,270 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="no-js" lang="en-GB">
|
||||
<head>
|
||||
<title>Include CSS Fonts by Using a SASS each Loop | Oliver Davies</title>
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
|
||||
<meta property="og:url" content="https://www.oliverdavies.uk/blog/2014/11/18/include-css-fonts-using-sass-each-loop">
|
||||
<meta property="og:title" content="Include CSS Fonts by Using a SASS each Loop"/>
|
||||
|
||||
|
||||
|
||||
<meta property="og:image" content="https://www.oliverdavies.uk/assets/images/me-precedent.jpg"/>
|
||||
<meta property="og:image:height" content="327"/>
|
||||
<meta property="og:image:type" content="image/jpg">
|
||||
<meta property="og:image:width" content="327"/>
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://www.oliverdavies.uk/assets/css/main.css">
|
||||
<link rel="stylesheet" href="https://www.oliverdavies.uk/assets/css/blog-post.css">
|
||||
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=57" sizes="57x57">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=114" sizes="114x114">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=72" sizes="72x72">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=144" sizes="144x144">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=60" sizes="60x60">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=120" sizes="120x120">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=76" sizes="76x76">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=152" sizes="152x152">
|
||||
|
||||
<link rel="icon" href="/assets/images/me-precedent.jpg?s=160" sizes="160x160">
|
||||
<link rel="icon" href="/assets/images/me-precedent.jpg?s=96" sizes="96x96">
|
||||
<link rel="icon" href="/assets/images/me-precedent.jpg?s=32" sizes="32x32">
|
||||
<link rel="icon" href="/assets/images/me-precedent.jpg?s=16" sizes="16x16">
|
||||
</head>
|
||||
<body class="">
|
||||
<nav class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="https://www.oliverdavies.uk/">Oliver Davies</a>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="collapse navbar-collapse" role="navigation">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="">
|
||||
<a href="/">About</a>
|
||||
</li>
|
||||
|
||||
<li class="">
|
||||
<a href="/experience">Experience</a>
|
||||
</li>
|
||||
|
||||
<li class="">
|
||||
<a href="/testimonials">Testimonials</a>
|
||||
</li>
|
||||
|
||||
<li class="">
|
||||
<a href="/talks">Talks</a>
|
||||
</li>
|
||||
|
||||
<li class="active">
|
||||
<a href="/blog">Blog</a>
|
||||
</li>
|
||||
|
||||
<li class="">
|
||||
<a href="/contact">Contact</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div> </div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<main class="col-md-9">
|
||||
<h1>Include CSS Fonts by Using a SASS each Loop</h1>
|
||||
|
||||
<p class="posted">18th November 2014</p>
|
||||
|
||||
<p>Using a file structure similar to this, organise your font files into directories, using the the font name for both the directory name and for the file names.</p>
|
||||
|
||||
<pre><code class="language-bash">.
|
||||
├── FuturaBold
|
||||
│ ├── FuturaBold.eot
|
||||
│ ├── FuturaBold.svg
|
||||
│ ├── FuturaBold.ttf
|
||||
│ └── FuturaBold.woff
|
||||
├── FuturaBoldItalic
|
||||
│ ├── FuturaBoldItalic.eot
|
||||
│ ├── FuturaBoldItalic.svg
|
||||
│ ├── FuturaBoldItalic.ttf
|
||||
│ └── FuturaBoldItalic.woff
|
||||
├── FuturaBook
|
||||
│ ├── FuturaBook.eot
|
||||
│ ├── FuturaBook.svg
|
||||
│ ├── FuturaBook.ttf
|
||||
│ └── FuturaBook.woff
|
||||
├── FuturaItalic
|
||||
│ ├── FuturaItalic.eot
|
||||
│ ├── FuturaItalic.svg
|
||||
│ ├── FuturaItalic.ttf
|
||||
│ └── FuturaItalic.woff
|
||||
</code></pre>
|
||||
|
||||
<p>Within your SASS file, start an <code>@each</code> loop, listing the names of the fonts. In the same way as PHP's <code>foreach</code> loop, each font name will get looped through using the <code>$family</code> variable and then compiled into CSS.</p>
|
||||
|
||||
<pre><code class="language-scss">@each $family in FuturaBook, FuturaBold, FuturaBoldItalic, FuturaItalic {
|
||||
@font-face {
|
||||
font-family: #{$family};
|
||||
src: url('../fonts/#{$family}/#{$family}.eot');
|
||||
src: url('../fonts/#{$family}/#{$family}.eot?#iefix') format('embedded-opentype'),
|
||||
url('../fonts/#{$family}/#{$family}.woff') format('woff'),
|
||||
url('../fonts/#{$family}/#{$family}.ttf') format('truetype'),
|
||||
url('../fonts/#{$family}/#{$family}.svg##{$family}') format('svg');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
<p>When the CSS has been compiled, you can then use in your CSS in the standard way.</p>
|
||||
|
||||
<pre><code class="language-scss">font-family: "FuturaBook";
|
||||
</code></pre>
|
||||
|
||||
<p class="tags">
|
||||
Tags:
|
||||
<a href="https://www.oliverdavies.uk/blog/tags/compass">compass</a>, <a href="https://www.oliverdavies.uk/blog/tags/drupal-planet">drupal-planet</a>, <a href="https://www.oliverdavies.uk/blog/tags/fonts">fonts</a>, <a href="https://www.oliverdavies.uk/blog/tags/sass">sass</a> </p>
|
||||
<div class="post-pager is-flex">
|
||||
<div class="is-half">
|
||||
<a href="/blog/2014/10/21/updating-features-and-adding-components-using-drush">
|
||||
« Updating Features and Adding Components Using Drush
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="is-half text-right">
|
||||
<a href="/blog/2014/11/20/using-remote-files-when-developing-locally-with-stage-file-proxy-module">
|
||||
Using Remote Files when Developing Locally with Stage File Proxy Module »
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="about-author">
|
||||
<h2>About the Author</h2>
|
||||
|
||||
<img src="//images.oliverdavies.uk/assets/images/me-precedent.jpg" alt="Picture of Oliver" class="img-circle">
|
||||
|
||||
<p>Oliver Davies is a Web Developer, System Administrator and Drupal specialist based in the UK. He is a Senior Developer at <a href="https://microserve.io">Microserve</a> and also provides freelance consultancy services for Drupal websites, PHP applications and Linux servers.</p>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="panel badges text-center">
|
||||
<a class="badge--da-member" href="https://assoc.drupal.org/membership" title="I’m a Drupal Association member.">
|
||||
<img
|
||||
src="//images.oliverdavies.uk/assets/images/da-individual-member.png"
|
||||
alt="Drupal Association Individual Member"
|
||||
width="152"
|
||||
>
|
||||
</a>
|
||||
|
||||
<a href="http://drupalcores.com/#opdavies">
|
||||
<img
|
||||
alt="I built Drupal 8 with hand holding a wrench on blue background"
|
||||
src="//images.oliverdavies.uk/assets/images/drupal-8.jpg"
|
||||
/>
|
||||
</a>
|
||||
|
||||
<img
|
||||
src="//images.oliverdavies.uk/assets/images/badges/acquia-certified-developer-drupal-8.png"
|
||||
alt="Acquia Certified Developer - Drupal 8 Exam Badge"
|
||||
height="147" width="147"
|
||||
/>
|
||||
|
||||
<a href="http://conference.phpnw.org.uk/phpnw17">
|
||||
<img src="//images.oliverdavies.uk/assets/images/badges/phpnw17.png" alt="">
|
||||
</a>
|
||||
</div>
|
||||
<div class="availability panel panel-default">
|
||||
<div class="panel-heading">Availability</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<p>
|
||||
<i class="fa fa-thumbs-o-up text-warning"></i>
|
||||
|
||||
|
||||
Currently have limited part-time capacity
|
||||
</p>
|
||||
<p>
|
||||
<i class="fa fa-thumbs-o-down text-danger"></i>
|
||||
|
||||
Currently no spare full-time capacity.
|
||||
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="latest-posts panel panel-default">
|
||||
<div class="latest-posts__heading panel-heading">Latest blog posts</div>
|
||||
|
||||
<ul class="list-group">
|
||||
<li class="post list-group-item">
|
||||
<span class="post__title">
|
||||
<a href="/blog/2017/06/09/introducing-the-drupal-meetups-twitterbot">
|
||||
Introducing the Drupal Meetups Twitterbot
|
||||
</a>
|
||||
</span> -
|
||||
<span class="post__date">9th June, 2017</span>
|
||||
</li>
|
||||
<li class="post list-group-item">
|
||||
<span class="post__title">
|
||||
<a href="/blog/2017/05/20/turning-drupal-module-into-feature">
|
||||
Turning Your Custom Drupal Module into a Feature
|
||||
</a>
|
||||
</span> -
|
||||
<span class="post__date">20th May, 2017</span>
|
||||
</li>
|
||||
<li class="post list-group-item">
|
||||
<span class="post__title">
|
||||
<a href="/blog/2017/05/15/drupalcamp-bristol-early-bird-tickets-sessions-sponsors">
|
||||
DrupalCamp Bristol 2017 - Early Bird Tickets, Call for Sessions, Sponsors
|
||||
</a>
|
||||
</span> -
|
||||
<span class="post__date">15th May, 2017</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> </div>
|
||||
<footer class="container">
|
||||
<p class="copyright">
|
||||
© 2010-2017 Oliver Davies. Built with <a href="https://sculpin.io">Sculpin</a>.
|
||||
</p>
|
||||
|
||||
<div class="meetups">
|
||||
<h2>Things that I organise</h2>
|
||||
<ul>
|
||||
<li class="meetups--drupal-bristol">
|
||||
<a href="http://www.drupalbristol.org.uk" title="Drupal Bristol">
|
||||
<img src="//images.oliverdavies.uk/assets/images/meetups/drupal-bristol.jpeg" alt="Drupal Bristol">
|
||||
</a>
|
||||
</li>
|
||||
<li class="meetups--drupalcamp-bristol">
|
||||
<a href="http://www.drupalcampbristol.co.uk" title="DrupalCamp Bristol">
|
||||
<img src="//images.oliverdavies.uk/assets/images/meetups/drupalcamp-bristol.png" alt="DrupalCamp Bristol">
|
||||
</a>
|
||||
</li>
|
||||
<li class="meetups--phpsw">
|
||||
<a href="http://phpsw.uk" title="PHPSW">
|
||||
<img src="//images.oliverdavies.uk/assets/images/meetups/phpsw.jpeg" alt="PHPSW">
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://www.oliverdavies.uk/assets/js/site.js"></script>
|
||||
|
||||
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-11967257-1', 'auto'); ga('send', 'pageview');</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,243 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="no-js" lang="en-GB">
|
||||
<head>
|
||||
<title>Using Remote Files when Developing Locally with Stage File Proxy Module | Oliver Davies</title>
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
|
||||
<meta property="og:url" content="https://www.oliverdavies.uk/blog/2014/11/20/using-remote-files-when-developing-locally-with-stage-file-proxy-module">
|
||||
<meta property="og:title" content="Using Remote Files when Developing Locally with Stage File Proxy Module"/>
|
||||
|
||||
|
||||
|
||||
<meta property="og:image" content="https://www.oliverdavies.uk/assets/images/me-precedent.jpg"/>
|
||||
<meta property="og:image:height" content="327"/>
|
||||
<meta property="og:image:type" content="image/jpg">
|
||||
<meta property="og:image:width" content="327"/>
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://www.oliverdavies.uk/assets/css/main.css">
|
||||
<link rel="stylesheet" href="https://www.oliverdavies.uk/assets/css/blog-post.css">
|
||||
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=57" sizes="57x57">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=114" sizes="114x114">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=72" sizes="72x72">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=144" sizes="144x144">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=60" sizes="60x60">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=120" sizes="120x120">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=76" sizes="76x76">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=152" sizes="152x152">
|
||||
|
||||
<link rel="icon" href="/assets/images/me-precedent.jpg?s=160" sizes="160x160">
|
||||
<link rel="icon" href="/assets/images/me-precedent.jpg?s=96" sizes="96x96">
|
||||
<link rel="icon" href="/assets/images/me-precedent.jpg?s=32" sizes="32x32">
|
||||
<link rel="icon" href="/assets/images/me-precedent.jpg?s=16" sizes="16x16">
|
||||
</head>
|
||||
<body class="">
|
||||
<nav class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="https://www.oliverdavies.uk/">Oliver Davies</a>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="collapse navbar-collapse" role="navigation">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="">
|
||||
<a href="/">About</a>
|
||||
</li>
|
||||
|
||||
<li class="">
|
||||
<a href="/experience">Experience</a>
|
||||
</li>
|
||||
|
||||
<li class="">
|
||||
<a href="/testimonials">Testimonials</a>
|
||||
</li>
|
||||
|
||||
<li class="">
|
||||
<a href="/talks">Talks</a>
|
||||
</li>
|
||||
|
||||
<li class="active">
|
||||
<a href="/blog">Blog</a>
|
||||
</li>
|
||||
|
||||
<li class="">
|
||||
<a href="/contact">Contact</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div> </div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<main class="col-md-9">
|
||||
<h1>Using Remote Files when Developing Locally with Stage File Proxy Module</h1>
|
||||
|
||||
<p class="posted">20th November 2014</p>
|
||||
|
||||
<p>Download the <a href="https://www.drupal.org/project/stage_file_proxy">Stage File Proxy</a> module from Drupal.org and enable it on your site.</p>
|
||||
|
||||
<p>As this module is only going to be needed on pre-production sites, it would be better to configure this within your settings.php or settings.local.php file. We do this using the <code>$conf</code> array which removes the need to configure the module through the UI and store the values in the database.</p>
|
||||
|
||||
<pre><code class="language-php">// File proxy to the live site.
|
||||
$conf['stage_file_proxy_origin'] = 'http://www.example.com';
|
||||
|
||||
// Don't copy the files, just link to them.
|
||||
$conf['stage_file_proxy_hotlink'] = TRUE;
|
||||
|
||||
// Image style images are the wrong size otherwise.
|
||||
$conf['stage_file_proxy_use_imagecache_root'] = FALSE;
|
||||
</code></pre>
|
||||
|
||||
<p>If the origin site is not publicly accessible yet, maybe it's a pre-live or staging site, and protected with a basic access authentication, you can include the username and password within the origin URL.</p>
|
||||
|
||||
<pre><code class="language-php">$conf['stage_file_proxy_origin'] = 'http://user:password@prelive.example.com';
|
||||
</code></pre>
|
||||
|
||||
<p class="tags">
|
||||
Tags:
|
||||
<a href="https://www.oliverdavies.uk/blog/tags/drupal">drupal</a>, <a href="https://www.oliverdavies.uk/blog/tags/drupal-planet">drupal-planet</a>, <a href="https://www.oliverdavies.uk/blog/tags/servers">servers</a> </p>
|
||||
<div class="post-pager is-flex">
|
||||
<div class="is-half">
|
||||
<a href="/blog/2014/11/18/include-css-fonts-using-sass-each-loop">
|
||||
« Include CSS Fonts by Using a SASS each Loop
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="is-half text-right">
|
||||
<a href="/blog/2014/11/27/pantheon-settings-files">
|
||||
Include environment-specific settings files on Pantheon »
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="about-author">
|
||||
<h2>About the Author</h2>
|
||||
|
||||
<img src="//images.oliverdavies.uk/assets/images/me-precedent.jpg" alt="Picture of Oliver" class="img-circle">
|
||||
|
||||
<p>Oliver Davies is a Web Developer, System Administrator and Drupal specialist based in the UK. He is a Senior Developer at <a href="https://microserve.io">Microserve</a> and also provides freelance consultancy services for Drupal websites, PHP applications and Linux servers.</p>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="panel badges text-center">
|
||||
<a class="badge--da-member" href="https://assoc.drupal.org/membership" title="I’m a Drupal Association member.">
|
||||
<img
|
||||
src="//images.oliverdavies.uk/assets/images/da-individual-member.png"
|
||||
alt="Drupal Association Individual Member"
|
||||
width="152"
|
||||
>
|
||||
</a>
|
||||
|
||||
<a href="http://drupalcores.com/#opdavies">
|
||||
<img
|
||||
alt="I built Drupal 8 with hand holding a wrench on blue background"
|
||||
src="//images.oliverdavies.uk/assets/images/drupal-8.jpg"
|
||||
/>
|
||||
</a>
|
||||
|
||||
<img
|
||||
src="//images.oliverdavies.uk/assets/images/badges/acquia-certified-developer-drupal-8.png"
|
||||
alt="Acquia Certified Developer - Drupal 8 Exam Badge"
|
||||
height="147" width="147"
|
||||
/>
|
||||
|
||||
<a href="http://conference.phpnw.org.uk/phpnw17">
|
||||
<img src="//images.oliverdavies.uk/assets/images/badges/phpnw17.png" alt="">
|
||||
</a>
|
||||
</div>
|
||||
<div class="availability panel panel-default">
|
||||
<div class="panel-heading">Availability</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<p>
|
||||
<i class="fa fa-thumbs-o-up text-warning"></i>
|
||||
|
||||
|
||||
Currently have limited part-time capacity
|
||||
</p>
|
||||
<p>
|
||||
<i class="fa fa-thumbs-o-down text-danger"></i>
|
||||
|
||||
Currently no spare full-time capacity.
|
||||
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="latest-posts panel panel-default">
|
||||
<div class="latest-posts__heading panel-heading">Latest blog posts</div>
|
||||
|
||||
<ul class="list-group">
|
||||
<li class="post list-group-item">
|
||||
<span class="post__title">
|
||||
<a href="/blog/2017/06/09/introducing-the-drupal-meetups-twitterbot">
|
||||
Introducing the Drupal Meetups Twitterbot
|
||||
</a>
|
||||
</span> -
|
||||
<span class="post__date">9th June, 2017</span>
|
||||
</li>
|
||||
<li class="post list-group-item">
|
||||
<span class="post__title">
|
||||
<a href="/blog/2017/05/20/turning-drupal-module-into-feature">
|
||||
Turning Your Custom Drupal Module into a Feature
|
||||
</a>
|
||||
</span> -
|
||||
<span class="post__date">20th May, 2017</span>
|
||||
</li>
|
||||
<li class="post list-group-item">
|
||||
<span class="post__title">
|
||||
<a href="/blog/2017/05/15/drupalcamp-bristol-early-bird-tickets-sessions-sponsors">
|
||||
DrupalCamp Bristol 2017 - Early Bird Tickets, Call for Sessions, Sponsors
|
||||
</a>
|
||||
</span> -
|
||||
<span class="post__date">15th May, 2017</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> </div>
|
||||
<footer class="container">
|
||||
<p class="copyright">
|
||||
© 2010-2017 Oliver Davies. Built with <a href="https://sculpin.io">Sculpin</a>.
|
||||
</p>
|
||||
|
||||
<div class="meetups">
|
||||
<h2>Things that I organise</h2>
|
||||
<ul>
|
||||
<li class="meetups--drupal-bristol">
|
||||
<a href="http://www.drupalbristol.org.uk" title="Drupal Bristol">
|
||||
<img src="//images.oliverdavies.uk/assets/images/meetups/drupal-bristol.jpeg" alt="Drupal Bristol">
|
||||
</a>
|
||||
</li>
|
||||
<li class="meetups--drupalcamp-bristol">
|
||||
<a href="http://www.drupalcampbristol.co.uk" title="DrupalCamp Bristol">
|
||||
<img src="//images.oliverdavies.uk/assets/images/meetups/drupalcamp-bristol.png" alt="DrupalCamp Bristol">
|
||||
</a>
|
||||
</li>
|
||||
<li class="meetups--phpsw">
|
||||
<a href="http://phpsw.uk" title="PHPSW">
|
||||
<img src="//images.oliverdavies.uk/assets/images/meetups/phpsw.jpeg" alt="PHPSW">
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://www.oliverdavies.uk/assets/js/site.js"></script>
|
||||
|
||||
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-11967257-1', 'auto'); ga('send', 'pageview');</script>
|
||||
|
||||
</body>
|
||||
</html>
|
293
docs/blog/2014/11/27/pantheon-settings-files/index.html
Normal file
293
docs/blog/2014/11/27/pantheon-settings-files/index.html
Normal file
|
@ -0,0 +1,293 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="no-js" lang="en-GB">
|
||||
<head>
|
||||
<title>Include environment-specific settings files on Pantheon | Oliver Davies</title>
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
|
||||
<meta property="og:url" content="https://www.oliverdavies.uk/blog/2014/11/27/pantheon-settings-files">
|
||||
<meta property="og:title" content="Include environment-specific settings files on Pantheon"/>
|
||||
|
||||
|
||||
|
||||
<meta property="og:image" content="https://www.oliverdavies.uk/assets/images/me-precedent.jpg"/>
|
||||
<meta property="og:image:height" content="327"/>
|
||||
<meta property="og:image:type" content="image/jpg">
|
||||
<meta property="og:image:width" content="327"/>
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://www.oliverdavies.uk/assets/css/main.css">
|
||||
<link rel="stylesheet" href="https://www.oliverdavies.uk/assets/css/blog-post.css">
|
||||
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=57" sizes="57x57">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=114" sizes="114x114">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=72" sizes="72x72">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=144" sizes="144x144">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=60" sizes="60x60">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=120" sizes="120x120">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=76" sizes="76x76">
|
||||
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=152" sizes="152x152">
|
||||
|
||||
<link rel="icon" href="/assets/images/me-precedent.jpg?s=160" sizes="160x160">
|
||||
<link rel="icon" href="/assets/images/me-precedent.jpg?s=96" sizes="96x96">
|
||||
<link rel="icon" href="/assets/images/me-precedent.jpg?s=32" sizes="32x32">
|
||||
<link rel="icon" href="/assets/images/me-precedent.jpg?s=16" sizes="16x16">
|
||||
</head>
|
||||
<body class="">
|
||||
<nav class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="https://www.oliverdavies.uk/">Oliver Davies</a>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="collapse navbar-collapse" role="navigation">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="">
|
||||
<a href="/">About</a>
|
||||
</li>
|
||||
|
||||
<li class="">
|
||||
<a href="/experience">Experience</a>
|
||||
</li>
|
||||
|
||||
<li class="">
|
||||
<a href="/testimonials">Testimonials</a>
|
||||
</li>
|
||||
|
||||
<li class="">
|
||||
<a href="/talks">Talks</a>
|
||||
</li>
|
||||
|
||||
<li class="active">
|
||||
<a href="/blog">Blog</a>
|
||||
</li>
|
||||
|
||||
<li class="">
|
||||
<a href="/contact">Contact</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div> </div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<main class="col-md-9">
|
||||
<h1>Include environment-specific settings files on Pantheon</h1>
|
||||
|
||||
<p class="posted">27th November 2014</p>
|
||||
|
||||
<p>I was recently doing some work on a site hosted on <a href="http://getpantheon.com">Pantheon</a> and came across an issue, for which part of the suggested fix was to ensure that the <code>$base_url</code> variable was explicitly defined within settings.php (this is also best practice on all Drupal sites).</p>
|
||||
|
||||
<p>The way that was recommended was by using a <code>switch()</code> function based on Pantheon's environment variable. For example:</p>
|
||||
|
||||
<pre><code class="language-php">switch ($_SERVER['PANTHEON_ENVIRONMENT']) {
|
||||
case 'dev':
|
||||
// Development environment.
|
||||
$base_url = 'dev-my-site.gotpantheon.com';
|
||||
break;
|
||||
|
||||
|
||||
case 'test':
|
||||
// Testing environment.
|
||||
$base_url = 'test-my-site.gotpantheon.com';
|
||||
break;
|
||||
|
||||
|
||||
case 'live':
|
||||
// Production environment.
|
||||
$base_url = 'live-my-site.gotpantheon.com';
|
||||
break;
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
<p>Whilst this works, it doesn't conform to the DRY (don't repeat yourself) principle and means that you also might get a rather long and complicated settings file, especially when you start using multiple switches and checking for the value of the environment multiple times.</p>
|
||||
|
||||
<p>My alternative solution to this is to include an environment-specific settings file.</p>
|
||||
|
||||
<p>To do this, add the following code to the bottom of settings.php:</p>
|
||||
|
||||
<pre><code class="language-php">if (isset($_SERVER['PANTHEON_ENVIRONMENT'])) {
|
||||
if ($_SERVER['PANTHEON_ENVIRONMENT'] != 'live') {
|
||||
// You can still add things here, for example to apply to all sites apart
|
||||
// from production. Mail reroutes, caching settings etc.
|
||||
}
|
||||
|
||||
// Include an environment-specific settings file, for example
|
||||
// settings.dev.php, if one exists.
|
||||
$environment_settings = __DIR__ . '/settings.' . $_SERVER['PANTHEON_ENVIRONMENT'] . '.php';
|
||||
if (file_exists($environment_settings)) {
|
||||
include $environment_settings;
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
<p>This means that rather than having one long file, each environment has it's own dedicated settings file that contains it's own additional configuration. This is much easier to read and make changes to, and also means that less code is loaded and parsed by PHP. Settings that apply to all environments are still added to settings.php.</p>
|
||||
|
||||
<p>Below this, I also include a <a href="/blog/include-local-drupal-settings-file-environment-configuration-and-overrides/">similar piece of code</a> to include a settings.local.php file. The settings.php file then gets committed into the <a href="http://git-scm.com">Git</a> repository.</p>
|
||||
|
||||
<p>Within the sites/default directory, I also include an example file (example.settings.env.php) for reference. This is duplicated, renamed and populated accordingly.</p>
|
||||
|
||||
<pre><code class="language-php"><?php
|
||||
|
||||
/**
|
||||
* This is a specific settings file, just for the x environment. Any settings
|
||||
* defined here will be included after those in settings.php.
|
||||
*
|
||||
* If you have also added a settings.local.php file, that will override any
|
||||
* settings stored here.
|
||||
*
|
||||
* No database credentials should be stored in this file as these are included
|
||||
* automatically by Pantheon.
|
||||
*/
|
||||
|
||||
$base_url = '';
|
||||
</code></pre>
|
||||
|
||||
<p>The environment specific files are also committed into Git and pushed to Pantheon, and are then included automatically on each environment.</p>
|
||||
|
||||
<p class="tags">
|
||||
Tags:
|
||||
<a href="https://www.oliverdavies.uk/blog/tags/drupal">drupal</a>, <a href="https://www.oliverdavies.uk/blog/tags/drupal-planet">drupal-planet</a>, <a href="https://www.oliverdavies.uk/blog/tags/pantheon">pantheon</a>, <a href="https://www.oliverdavies.uk/blog/tags/settings.php">settings.php</a> </p>
|
||||
<div class="post-pager is-flex">
|
||||
<div class="is-half">
|
||||
<a href="/blog/2014/11/20/using-remote-files-when-developing-locally-with-stage-file-proxy-module">
|
||||
« Using Remote Files when Developing Locally with Stage File Proxy Module
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="is-half text-right">
|
||||
<a href="/blog/2014/12/20/include-local-drupal-settings-file-environment-configuration-and-overrides">
|
||||
Include a Local Drupal Settings file for Environment Configuration and Overrides »
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="about-author">
|
||||
<h2>About the Author</h2>
|
||||
|
||||
<img src="//images.oliverdavies.uk/assets/images/me-precedent.jpg" alt="Picture of Oliver" class="img-circle">
|
||||
|
||||
<p>Oliver Davies is a Web Developer, System Administrator and Drupal specialist based in the UK. He is a Senior Developer at <a href="https://microserve.io">Microserve</a> and also provides freelance consultancy services for Drupal websites, PHP applications and Linux servers.</p>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="panel badges text-center">
|
||||
<a class="badge--da-member" href="https://assoc.drupal.org/membership" title="I’m a Drupal Association member.">
|
||||
<img
|
||||
src="//images.oliverdavies.uk/assets/images/da-individual-member.png"
|
||||
alt="Drupal Association Individual Member"
|
||||
width="152"
|
||||
>
|
||||
</a>
|
||||
|
||||
<a href="http://drupalcores.com/#opdavies">
|
||||
<img
|
||||
alt="I built Drupal 8 with hand holding a wrench on blue background"
|
||||
src="//images.oliverdavies.uk/assets/images/drupal-8.jpg"
|
||||
/>
|
||||
</a>
|
||||
|
||||
<img
|
||||
src="//images.oliverdavies.uk/assets/images/badges/acquia-certified-developer-drupal-8.png"
|
||||
alt="Acquia Certified Developer - Drupal 8 Exam Badge"
|
||||
height="147" width="147"
|
||||
/>
|
||||
|
||||
<a href="http://conference.phpnw.org.uk/phpnw17">
|
||||
<img src="//images.oliverdavies.uk/assets/images/badges/phpnw17.png" alt="">
|
||||
</a>
|
||||
</div>
|
||||
<div class="availability panel panel-default">
|
||||
<div class="panel-heading">Availability</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<p>
|
||||
<i class="fa fa-thumbs-o-up text-warning"></i>
|
||||
|
||||
|
||||
Currently have limited part-time capacity
|
||||
</p>
|
||||
<p>
|
||||
<i class="fa fa-thumbs-o-down text-danger"></i>
|
||||
|
||||
Currently no spare full-time capacity.
|
||||
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="latest-posts panel panel-default">
|
||||
<div class="latest-posts__heading panel-heading">Latest blog posts</div>
|
||||
|
||||
<ul class="list-group">
|
||||
<li class="post list-group-item">
|
||||
<span class="post__title">
|
||||
<a href="/blog/2017/06/09/introducing-the-drupal-meetups-twitterbot">
|
||||
Introducing the Drupal Meetups Twitterbot
|
||||
</a>
|
||||
</span> -
|
||||
<span class="post__date">9th June, 2017</span>
|
||||
</li>
|
||||
<li class="post list-group-item">
|
||||
<span class="post__title">
|
||||
<a href="/blog/2017/05/20/turning-drupal-module-into-feature">
|
||||
Turning Your Custom Drupal Module into a Feature
|
||||
</a>
|
||||
</span> -
|
||||
<span class="post__date">20th May, 2017</span>
|
||||
</li>
|
||||
<li class="post list-group-item">
|
||||
<span class="post__title">
|
||||
<a href="/blog/2017/05/15/drupalcamp-bristol-early-bird-tickets-sessions-sponsors">
|
||||
DrupalCamp Bristol 2017 - Early Bird Tickets, Call for Sessions, Sponsors
|
||||
</a>
|
||||
</span> -
|
||||
<span class="post__date">15th May, 2017</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> </div>
|
||||
<footer class="container">
|
||||
<p class="copyright">
|
||||
© 2010-2017 Oliver Davies. Built with <a href="https://sculpin.io">Sculpin</a>.
|
||||
</p>
|
||||
|
||||
<div class="meetups">
|
||||
<h2>Things that I organise</h2>
|
||||
<ul>
|
||||
<li class="meetups--drupal-bristol">
|
||||
<a href="http://www.drupalbristol.org.uk" title="Drupal Bristol">
|
||||
<img src="//images.oliverdavies.uk/assets/images/meetups/drupal-bristol.jpeg" alt="Drupal Bristol">
|
||||
</a>
|
||||
</li>
|
||||
<li class="meetups--drupalcamp-bristol">
|
||||
<a href="http://www.drupalcampbristol.co.uk" title="DrupalCamp Bristol">
|
||||
<img src="//images.oliverdavies.uk/assets/images/meetups/drupalcamp-bristol.png" alt="DrupalCamp Bristol">
|
||||
</a>
|
||||
</li>
|
||||
<li class="meetups--phpsw">
|
||||
<a href="http://phpsw.uk" title="PHPSW">
|
||||
<img src="//images.oliverdavies.uk/assets/images/meetups/phpsw.jpeg" alt="PHPSW">
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://www.oliverdavies.uk/assets/js/site.js"></script>
|
||||
|
||||
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-11967257-1', 'auto'); ga('send', 'pageview');</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue