https://luisrc7.github.io/dcdublin17/
Simple presentation.
Target for beginners but developers.
Minimum knowledge, I will explain tools.
You can leave now!
Don't be afraid of the "command line" "console" "terminal"
It is easy and it will save you a lot of time.
VCS, Software to organise and control code revisions.
You can save your code locally or remotely and perform easily deployments or restorations.
Keep configuration in code, it can be tested.
Set up a repository.
If clone, specify a remote server like GitHub or Bitbucket.
Stage your local changes to be commited.
Save the staged changes into the local repository.
Save your changes to a branch in a remote repository.
Get the latest version of the code branch-repository.
Scripts you can run before or after a git action.
Useful one is pre-commit, you can define atomated tests or syntax check before commiting your code.
Drush is a command line interface for Drupal.
You can do the common drupal tasks with a command.
download/add/install/uninstall modules, clear caches, download database or files, etc.
Download a module, enable it or disable it.
drush dl views
It will install a drupal site from the drupal downloaded files.
drush site-install --db-url=mysql://DBuser:DBpass@localhost:port/DBname
You can download and install.
drush dl drupal-7.x
Build a drupal site from a predefined file, called makefile.
drush make d7example.make www
Import files between environments.
drush rsync @d7.dev:%files/ @d7.local:%files
You can exclude some folders with --exclude-paths.
Import a database between environments.
drush sql-dump --result-file=/tmp/prod.sql
drush sql-sync @d7.dev @d7.local
You can exclude some tables with --skip-tables-list.
Run the pending database updates.
drush updatedb -y
-y in any command will reply with Yes to all.
Dependency manager for PHP applications
Drupal is a PHP application.
Creates composer.json in the path.
Add an entry to the composer.json file.
composer require drupal/admin_toolbar
Is the main file where you require your project dependencies.
Install the defined/required dependencies in your project.
This file sets the versions for the composer.json dependencies.
If run install with a composer.lock file in your path will install all dependencies from composer.json but will get the specific versions from the composer.lock file.
You can include composer.lock in your repo.
"force" to update to the latest versions declared in composer.json and it will update your composer.lock
Of course, never update without testing it before.
A bunch of lines where we specify which modules, themes, folders, versions we want to install.
The very basic makefile would have just the Drupal core.
api = 2
core = 7.x
projects[drupal][type] = "core"
projects[drupal][version] = 7.56
If we want to add modules, we can specify version or path.
projects[views][version] = 3.18
projects[views][subdir] = "contrib"
There is also a way to add patches to your modules.
projects[ctools] = 3.x
projects[ctools][subdir] = "contrib"
projects[ctools][patch][] = "http://drupal.org/files/issues/example-patch.patch"
And different options to get your project.
projects[mytheme][download][type] = git
projects[mytheme][download][url] = "git://github.com/luisrc7/theme-repo.git"
projects[mytheme][download][tag] = 7.x-1.0
projects[mytheme][download][branch] = "feature-xxx"
libraries[ckeditor][download][type] = get
libraries[ckeditor][download][url] = "http://download.cksource.com/CKEditor/CKEditor/CKEditor%204.7.3/ckeditor_4.7.3_standard.zip"
libraries[ckeditor][destination] = libraries
Manually, or you can have a base installation already done and you want to export it with drush generate-makefile file.make.
Just run drush make file.make
1. Build the site from a makefile.
2. rsync our filesystem with drush.
3. sync the database with drush and clear sensitive data.
At this point we have our new site with the existing files and database from Production.
1. Run database updates.
2. Run database or custom scripts.
3. Run our tests, like behat.
I will leave this example to the end of the presentation if we have time.
Still not 100% working.
Composer integration with Drupal 8 is still "under development", and there are a few ways to accomplish what we want.
In the drupal documention page you will find more information. https://www.drupal.org/docs/develop/using-composer/using-composer-with-drupal
I am going to follow the Drupal Composer method.
This tool will give us a structure and base from where we could start.
First download/create the composer.json file with this command.
composer create-project drupal-composer/drupal-project:8.x-dev www
From there we can start including our dependencies - modules, themes, etc.
composer require drupal/devel:~1.0
"extra": {
"patches": {
"drupal/devel": {
"Patch description": "http://drupal.org/files/issues/example-patch.patch"
}
}
}
"scripts": {
"drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold",
"post-install-cmd": [
"@drupal-scaffold",
],
"post-update-cmd": [
"@drupal-scaffold",
]
}
There is also a module to generate this composer.json from an existing site. Composer Generate.
https://www.drupal.org/project/composer_generate