Drupal

DrupalEasy: Drupal 8 Development on Windows - Best Practices?

Planet Drupal - 3 February 2018 - 11:34am

Over the past several weeks, I've been working with three of the more well-known Docker-based local development environments that involve a Drupal focus: Docksal, DDEV, and Lando. The goal is to not only to figure out which one I prefer, but also to figure out which our two long-form online Drupal training classes should potentially standardize on.

Our classes are often comprised of folks from all different technical backgrounds, so it is important that we not only teach them tools that Drupal professionals use, but also something that folks of myriad of skill levels can easily consume. Perhaps most importantly, while the majority of our students are on Mac OS X, we still have a consistent number of students using Windows, so any solution we recommend should work similarly on all platforms.

As a Mac OS X user myself, it is important to me that I can instruct our Windows-based students without having to resort to a separate set of instructions. To that end, I have an actual Windows 10 Pro machine (not a virtual machine) that I've been using to evaluate these local development environment options. 

I've decided to focus on DDEV, Lando, and Docksal because I really like the idea of Docker-based containers; being able to customize your local development environments to each project has too many advantages to ignore. Also, as one of our classes is Pantheon-focused, Lando's Pantheon integration is a very important differentiator. 

Requirements

I have a basic set of requirements that a local development environment should be able to handle. These requirements are probably focused more on our introductory Drupal Career Online course, but I'd like to be able to recommend the same solution for any of our courses.

  • Run Composer commands (including create-project). It doesn't matter to me if this command is run on the local OS or in a container, as long as it works with a minimum of fuss. The "create-project" command can be a bit tricky on Windows - keep reading to find out why.
  • Run Git commands both on the local OS and in the container. 
  • Be able to get up-and-running with a minimum of downloads. On Mac OS X this isn't much of an issue with Terminal, Git, and PHP preinstalled, but on Windows it is a different story.
  • Be able to get up-and-running with a minimum of "extra" configuration. Granted, once you're comfortable on the command line adding something to your local PATH isn't a big deal, but for folks new-ish to the command line, it can be a significant hurdle. 
  • Have a Linux-based command line interface (to use commands like cd, ls, cat, etc...)
  • Be able to easily (zero configuration) edit text files on the command line (nano or pico).
  • Be able to modify file permissions and ownership from the command line (chown and chmod).
  • Be able to run Drush, Drupal Console, and all of the other Drupal-y things that a professional developer should have.

I am very cognizant that my requirements are probably represent the lower-end of the Drupal skill-level spectrum, but I feel these requirements are a reasonable starting point.

Potential solution

Over the past few weeks, I think I've installed, uninstalled, and reinstalled various combinations of Lando, Docksal, and DDEV as well as various command line shells (Babun, Cmder, PuTTY, Cygwin) and the Windows Subsystem for Linux at least a dozen times on my Windows machine. All this in an effort to figure out what is the best combination of tools to satisfy the requirements. At the current moment, I'm circling around recommending Lando and Cmder on Windows (Lando requires Windows 10 Pro with Hyper-V enabled) - both are easily installed with no extra configuration necessary to get almost everything working. 

Upsides

With just Lando and Cmder installed almost all of the requirements are met. I can use Git to clone a site down to my local, get it up and running in Lando and get to work.

Downsides

One minor issue is that Cmder doesn't come with nano nor pico for editing text files from the command line. It does come with vim, however (which we all know has a steeper learning curve). I can probably mitigate this issue with a little bit of config to have students run a command to open text files in something like Notepad++ or teach some basic vim commands.

The other issue is a bit more serious. With only Lando and Cmder installed, there's no way to run "composer create-project". While Lando makes Composer available in the container, developers don't normally create the containers until they have a code base. This is a bit of a chicken-and-egg issue:

  1. We need Composer to get the new code base.
  2. We need the Lando container to be up-and-running to get Composer.
  3. We need a code base before we start Lando.
  4. (return to step 1 above)

So, I think I know what you're thinking: just install Composer. Well, this isn't as simple as it sounds, as Composer requires PHP, and as far as I can tell, installing PHP on a Windows machine isn't super-straight-forward. Granted, if the developer already has another AMP stack on their Windows machine, the Composer install can be configured to use the php.exe installed with it. 

Docksal actually has a command that allows a developer to run Composer without actually having a set of containers already initialized for the project using the "fin run-cli" command. This utilizes a standalone cli container and completely removes the need to install Composer on the local OS. 

Next steps

So, where does that leave us? I'm not 100% sure, but I wanted to put this out there and get some feedback. Are you a professional Drupal developer that uses Windows as your main OS? If so, what's your setup? Am I missing anything? 

While I often try to steer new Drupal developers towards Mac OS X or Linux, sometimes it is not possible due to corporate policies or even just personal preference. I'd love to be able to teach a solution that provides a professional-level Drupal developer experience to Windows users.

Categories: Drupal

Drupal Association blog: Drupal User Research - Call for Interviews

Planet Drupal - 3 February 2018 - 7:46am

The Drupal Association is mapping Drupal’s customer lifecycle and defining the personas who have decision making authority throughout the adoption and user journeys. Our goal is to understand how to better serve each persona at DrupalCon and on Drupal.org, in turn growing Drupal adoption and more effectively helping those working on or with Drupal to become power users

To start this project, we need to interview different types of people working with Drupal.

Will you donate 45 minutes of your time to participate in a user research call?

We are looking for people in the following job functions who work with Drupal.

Job Functions:

  • CEO
  • CMO, VP marketing
  • CTO/CIO/ Director of engineering
  • Chief Information Marketing Office
  • Chief / Lead / Tech architect
  • Developer
  • Project manager
  • Marketing technologist
  • Content strategist
  • Content author / Content editor
  • Trainers of content editors
  • UX designer
  • Customer experience manager
  • Marketing campaign manager/director
  • Purchaser/procurement
If you are interested in participating in a user research call, please sign up here by February 16, 2018 and we will contact you.
Categories: Drupal

Menu file

New Drupal Modules - 3 February 2018 - 6:44am

Provides the possibility to upload a file to a menu item. The file URL will be used as link.

The relation between menu links and files will be stored in the database and will be updated each time the file changes.

Categories: Drupal

Translate Export

New Drupal Modules - 3 February 2018 - 4:16am

Translate export module is helpful to export strings. it supports export single string, select multi strings to export. it's useful when you need export strings frequently and don't want to export whole group of strings.

Categories: Drupal

Baidu Push

New Drupal Modules - 2 February 2018 - 9:05pm

The Baidu Push module allows to let the Baidu search engine (the most used search engine in China Mainland) know about your publicly accessible pages.

Categories: Drupal

Address Field India

New Drupal Modules - 2 February 2018 - 7:52pm

This module is a plugin for Address field module. It provides an Indian address form.

Address Data for all Indian states can be downloaded from https://data.gov.in/resources/villagelocality-based-pin-mapping-16th-mar...

The formatted data CSV for this module can be downloaded from https://github.com/rahulbile/india-state-villages

Categories: Drupal

Commerce Demo

New Drupal Modules - 2 February 2018 - 3:10pm

Provides a demo store for Commerce 2.x.

Categories: Drupal

Layout builder library

New Drupal Modules - 2 February 2018 - 2:27pm
Overview

Provides a layout library allowing content editors to pick from a list of pre-defined layouts.

Features

Site builders can create and deploy pre-defined layouts for each entity-type and bundle combination.
Content editors can pick from existing layouts.
Site admins can prevent content-editors from creating their own bespoke layouts but give them the ability to customise layouts on a per-content-item basis.

Requirements

Layout builder (in core)
Layout discovery (in core)
Field UI (in core)

Categories: Drupal

Promet Source: Promet Source Receives 2018 AVA Digital Award for Martin County Florida Drupal Web Development

Planet Drupal - 2 February 2018 - 12:32pm
Promet Source has been named among the Gold level winners of the 2018 AVA Digital Awards for outstanding work on the Martin County Florida Drupal website development project in the government category.              
Categories: Drupal

Menu Link Highlight

New Drupal Modules - 2 February 2018 - 12:02pm

Menu Link Highlight is a module that adds a highlight-class to a menu-item with a simple checkbox.

There are other modules available to add classes and other attributes to menu items, but for some end-users that's a way to mess things up. A simple checkbox to highlight the menu-item is a clean solution for this.

A class is added to the menu-item '< li >'-element.

Categories: Drupal

Menus Search

New Drupal Modules - 2 February 2018 - 11:26am
Categories: Drupal

Building bikes for the Boys and Girls Club

Dries Buytaert - 2 February 2018 - 10:53am

Throughout the years, the team at Acquia has heard me talk about doing well and doing good. We've embedded this philosophy into Acquia's culture since we started the company. As a result, one of Acquia's core values is to "give back more".

The "give back more" principle recognizes that Acquia was born from community. We cherish our open source roots and contribute both time and talent to strengthen our communities. This means not only contributing to the open source communities that we are part of, but our local communities as well.

This week our global sales and marketing teams came together for a week of strategic planning and training. For one of our team building activities, we built 60 bikes for the children of the Boys and Girls Club of Boston! We felt that this was a special way to strengthen our team, in addition to being a great opportunity to give back.

The next day, five children from the Boys and Girls Club came to pick up their bikes in our closing session. It was very touching — a lot of our team got teary eyed. It made me very proud of what we were able to accomplish for our local community. I'm excited to continue to "give back more" in 2018.

Categories: Drupal

Paragraphs Preview Helper

New Drupal Modules - 2 February 2018 - 10:40am

In development

Categories: Drupal

Acquia Lightning Blog: Using the Configuration Installer with Lightning

Planet Drupal - 2 February 2018 - 9:07am
Using the Configuration Installer with Lightning Adam Balsam Fri, 02/02/2018 - 12:07

Installing a site with existing config has been a bit of a moving target in Drupal 8. At different times, I've recommended at least three different approaches. I won't go into too much detail, but basically we've used the following at times:

  • Manually change site UUIDs (Sloppy)
  • Use --config-dir option with drush site-install (Only supports minimal profile)
  • Use patch from Issue #2788777 (Config needs to be stored in profile directory)

You can read more about previous approaches here. The one thing that hasn't changed is the user story:

As a user I want to be able to install Drupal from a package of configuration that is maintained in git.

The issue that most closely addresses this user story is #1613424 "Allow a site to be installed from existing configuration". That issue is currently postponed on another thorny issue which involves the special way that Drupal treats dependencies of profiles. In the meantime, alexpott has provided a standalone install profile that handles installing a site from existing config. This is the Configuration installer profile.

It takes a minute to wrap your head around the concept because when you use the Configuration installer profile, you don't end up with a site running the Configuration installer profile. At the end of the install, your site will be running the profile that is defined in the config you provided the Config installer.

So for a new project, you would initially install using the profile of your choice. Then, once you have exported your config, you would use the Config installer for subsequent installs.

Considerations
  • For ease of use, your settings file should not be writable by the installer and should not contain the install_profile key. If your settings file contains your profile, you'll get an exception when trying to run the install. And if it is writable, Drupal will write that value every time you do install.
  • The Config installer profile requires two patches in order to work properly with Drush 9.
  • Config must not have direct dependencies on a profile. Lightning 3.0.1 requires the patch in issue #2933445 to be compliant.
Instructions
  1. For new sites, install using the profile or sub-profile of choice.
$ drush site-install lightning
  1. Ensure that the install_profile key is not present in your settings.php file. Drupal will write this value by default, but it is not required in Drupal >= 8.3.0. You can prevent Drupal from writing it by disallowing write access to the settings file. If the installer wrote the profile during initial installation, you can manually delete it. Then revoke write access:
$ chmod 444 docroot/sites/default/settings.php
  1. Define the following patches in your composer.json file if you are using config_installer < 1.6.0 and/or lightning < 3.0.2.
"patches": { "drupal/config_installer": { "2916090 - Support Drush 9": "https://www.drupal.org/files/issues/drush9-support-2916090-6.patch", "2935426 - Drush 9: Call to undefined function drush_generate_password": "https://www.drupal.org/files/issues/config_installer-drush_9_call_undefined_function_drush_generate_password-2935426-2.patch" }, "drupal/lightning_layout": { "2933445 - user.role.layout_manager has dependency on Lightning": "https://www.drupal.org/files/issues/2933445.patch" } },
  1. Add the Configuration installer profile to your codebase.
$ composer require drupal/config_installer
  1. Export your site's configuration.
$ drush config-export
  1. Use the Configuration installer profile in all subsequent site installs. The resulting install will run on the profile used in step 1.
$ drush site-install config_installer
Categories: Drupal

Context Fourohfour

New Drupal Modules - 2 February 2018 - 8:42am

Context reaction to stop page delivery and set basic header response.

Works great for DomainAPI related path issues!

    ie:
  • Views page specific for a domain child,
  • node types to 404 rather than unauthorized (login screen)
Categories: Drupal

Rest Normalizer

New Drupal Modules - 2 February 2018 - 5:49am

Nowaday's you often heard of a phrase "Headless Drupal or Decoupled Architecture" It is rising in popularity in the development world. This model allows breakthrough user experiences, gives developers great flexibility to innovate, and helps site owners future-proof their builds by allowing them to refresh the design without re-implementing the whole CMS.

Categories: Drupal

Ubercart PayPal Plus

New Drupal Modules - 2 February 2018 - 3:20am

This is an Ubercart payment gateway module for PayPal Plus.

For further instructions, see the README.txt included with the module. You must install Ubercart for this module to work.

Categories: Drupal

drunken monkey: Some more (updated) tips for PhpStorm live templates

Planet Drupal - 2 February 2018 - 3:19am

A few years ago I started using the PhpStorm IDE for PHP development, was immediately smitten and, after a bit of use, wrote a blog post with some tips I found for makig better use of the tools PhpStorm gives you.

In the four years since then there have been some new developments. Firstly, of course, Drupal 8 was finally released – and, consequently, the one complaint I had back in 2013 about the $MODULE$ variable only working in the module file itself became more of a problem. (Also, I added one more live template that's very useful for Drupal 8.)
But secondly, a few weeks ago PhpStorm finally added scripting support for live templates, so it's now possible to write more powerful templates that way – and fix the $MODULE$ variable.

The new di live template

In general, when writing OOP code for Drupal 8 (that is, for almost all Drupal 8 code) you should use dependency injection as much as possible. There's several different styles for doing that, I'm using one which uses setter methods and calls them in create() (instead of adding all injected objects to the constructor). This makes inheritance easier and keeps the constructor “cleaner” – and becomes much easier with a good live template:

  /**
   * The $NAME$.
   *
   * @var $INTERFACE$|null
   */
  protected $$$PROP_NAME$;

  /**
   * Retrieves the $NAME$.
   *
   * @return $INTERFACE$
   *   The $NAME$.
   */
  public function get$UC_PROP_NAME$() {
    $plugin->set$UC_PROP_NAME$($container->get('$SERVICE$'));

    return $this->$PROP_NAME$ ?: \Drupal::service('$SERVICE$');
  }

  /**
   * Sets the $NAME$.
   *
   * @param $INTERFACE$ $$$VAR_NAME$
   *   The new $NAME$.
   *
   * @return $this
   */
  public function set$UC_PROP_NAME$($INTERFACE$ $$$VAR_NAME$) {
    $this->$PROP_NAME$ = $$$VAR_NAME$;
    return $this;
  }

Variable definitions:

Name Expression Skip if defined VAR_NAME N SERVICE N INTERFACE clipboard() Y NAME underscoresToSpaces(VAR_NAME) Y UC_NAME underscoresToCamelCase(VAR_NAME) Y UC_PROP_NAME capitalize(PROP_NAME) Y

Usage:

  1. Copy the service interface's FQN to your clipboard.
  2. Put the service ID either into a secondary clipboard (e.g., middle mouse button on Linux) or remember it.
  3. Execute live template (at the position where you want the getter and setter).
  4. Input variable name (in snake_case), then input service name.
  5. Move the property definition and the create() line (temporarily stored as the first line of the getter in the template) to their appropriate places.
  6. In the code, alway use the getter method for accessing the service.
Fixing the $MODULE$ variable

Since the code for this is quite complex, we better just put it into a separate file. So, first download the script file and save it to some known location, then simply use the (absolute) path to the script file as the argument for groovyScript(), like this:

This can be used for all the live templates that contain a $MODULE$ variable (though it will, of course, be less useful for the procedural ones, than for the simple m template).

Categories: Drupal

Simple Zoom

New Drupal Modules - 2 February 2018 - 3:02am

The "Simple Zoom" module allows you to open the image in a popup. The module creates a image formatter and a CKEditor plugin for opening the image fields and inline images in popup using simple jquery zoom plugin.

Categories: Drupal

OneLogin Integration

New Drupal Modules - 2 February 2018 - 1:38am

With this module, you can log in with OneLogin through SAML in Drupal 8. This module is a rebuild of this module, which is only available in Drupal 7. Because of this, I rebuilt it for Drupal 8.

More information will come at a later stage.

Categories: Drupal

Pages

Subscribe to As If Productions aggregator - Drupal