Drupal

There are usually many good ways to solve problems in computer science. Some are better or worse than others, most are just different than others.

There are also many pieces to the puzzle of creating a Drupal website. Each piece of the puzzle is a story in itself. Every detail is important. The context is also important.

This general overview will help you understand the context that each of the individual programs work in. Understanding the context will help you understand how and why each piece of the puzzle does what it does.

Keep in mind that I am not a professional programmer, so be careful, double check everything. You can use this story as a guide for your own investigation. It will help you learn what to look for. I have used the procedures described in this story to build a website on my computer.

It is just an example, to help you get a big picture of the process embedded into your long term memory. You will build on that memory by reading more documentation, experimenting and actually building your own websites.

Composer is the tool you use to install Drupal. It will install the Drupal Core and any modules you add, in the right way in the right place. Drush is a tool you use to command Drupal to do things. Drupal Console is another tool that I don’t know much about, yet.

The way I learned how to do this is to install Lando and build my websites in instances of Lando. You can install Console, Drush and Drupal Console globally on your computer and then install each individual Drupal website in a separate instance of Lando, in a directory for that website.

The way I’ve done all this is by installing Lando. Create a sites directory in your file browser and cd into it. mkdir another directory for each website inside your sites folder.

Inside each website directory you enter the command, ‘lando init’. This automatically installs, composer, drush and drupal console.

lando init    # creates a new site with a .yml config file.
lando start   # takes a few minutes to start up an instance of Lando.

Install Drupal from Github repository.

lando composer create-project drupal-composer/drupal-project:8.x-dev drupal --stability dev --no-interaction --no-dev

Create an alias for getting that drupal project from github

Put all the files and folders in the right place.

mv drupal/* .
mv drupal/.* .
rm -rf drupal

Sites

Add Git repo

First, navigate to your .gitignore file and edit it by deleting the top section. Then exit out of there and get into your main project file.

git init
git add .

git add . adds all the files that are being tracked. git add -A adds all the files in the list, including untracked files.

git commit -m "initial commit"

I used this process to create a Drupal website on my computer several years ago. I’m having a hard time understanding my own notes. It seems to me like you would cd into your project directory and enter the git init command. Then you would cd into your .gitignore file and get it set up the way you want it. Then cd back to your project file and then, git add . or git add -A.

Lando seems like some kind of container technology.

I install the recipe I like with these commands:

lando composer require drupal/admin_toolbar drupal/pathauto drupal/zurb_foundation drupal/paragraphs drupal/fontawesome drupal/fontyourface --update-no-dev 
git add -A
git commit -m "require admin_toolbar pathauto paragraphs zurb_foundation fontawesome fontyourface"

I’ve enabled @fontyourface – Font Squirrel. I also added the entity_usage module in order to enable paragraphs_library

Install drupal in browser

database configuration:

drupal8
drupal8
drupal8

Advanced options:

Host: database

Do not save credentials

install website
configure website

Save credentials

Note: The lando composer require command used above is adding the modules and this lando drush en -y is enabling them.

lando drush en -y admin_toolbar admin_toolbar_tools pathauto paragraphs fontawesome fontyourface

You can also add and enable modules from the graphical Drupal 8 admin>extend page.

git add -A
git commit -m "admin_toolbar admin_toolbar_tools pathauto paragraphs fontawesome fontyourface"

SSH

ssh into remote server

ssh homeoffi@homeoffice.studio  

create new site directory inside www

mkdir ~/www/homeoffice

Change directory into new directory

cd ~/www/homeoffice

add new remote repository

git init in homeoffice

Added new remote repository in local project

git remote add origin homeoffi@homeoffice.studio:www/homeoffice

git

  • git add
  • git commit
  • git push
  • git pull
  • git merge master

add commit push – move into remote server – merge master into live

So, first you mkdir your sites directory, then your sites/website directories. Then you install Lando. You lando init in each individual website directory. Once you’ve initiated a lando site, you use lando start, to start it each time you want to work on it. And lando stop when your done working on it, to prevent it from running in the background, using up your computer’s resources.

As soon as you get your lando instance created you git init a git repository in each website directory. You’ve got to get that fairly cumbersome git workflow learned. It’s an important piece of the puzzle, whether you use PHP or Python.

The next big piece of the puzzle is the ssh workflow. Learn how to create your private and public keys. Then ssh into the remote server at your website hosting company.

After spending many hours and months and thousands of dollars trying to figure all this out, I finally gave up and started building this current WordPress website. Its working great. I’m still investigating how to setup and work with a local development environment. WordPress seems like the artist platform.

I’m planning on developing Python web applications instead of PHP ones. The main reason is that Python is way more versatile than PHP. You can build web applications that run in a web browser and native applications that run on your desktop. Python is also used in the development of artificial intelligence. And Python is more science and business oriented, while PHP and Drupal are more popular in the government and non-profit communities.