Checking if code covers coding standards.
Codesniffer
composer require --dev "squizlabs/php_codesniffer=*"
Coder module with the Drupal standards
<?php | |
#tests/src/Unit/FibonacciServiceTest.php | |
namespace Drupal\Tests\drupalup_fibo\Unit; | |
use Drupal\Tests\UnitTestCase; | |
use Drupal\drupalup_fibo\FibonacciService; | |
/** | |
* Our unit test for the fibonacci service. |
settings.php | |
$settings['custom_var'] = '55'; | |
then | |
use Drupal\Core\Site\Settings; | |
$my_var = settings::get('custom_var', '66') ; |
composer create-project drupal-composer/drupal-project:8.x-dev some-dir --no-interaction | |
../vendor/bin/drush site:install --db-url=mysql://DB_ROOT:DB_PASS@localhost:3306/DB_NAME |
{% include active_theme_path() ~ '/images/picture.png' %} |
$locale_storage = Drupal::service('locale.storage'); | |
$f_name_string_source = $locale_storage->getStrings(['source' => 'First name'], []); | |
if (!empty(reset($f_name_string_source))) { | |
$f_name_string_source = reset($f_name_string_source); | |
$f_name_string = $locale_storage->getTranslations(['language' => 'ro', 'lid' => $f_name_string_source->lid], []); | |
if (!empty(reset($f_name_string))) { | |
$f_name_string = reset($f_name_string); | |
if (!$f_name_string->isNew()) { |
# create a db backup | |
drush sql-dump | gzip > drupal_up_28_05_2018_2145.sql.gz | |
# import db backup | |
gunzip < drupal_up_28_05_2018_2145.sql.gz | drush sqlc | |
# Simple create patch from changes in your git repo | |
git diff HEAD path-to-changed-file > description-of-patch.patch | |
# Creating a patch from a special branch. | |
# 1. I am on a feature page. | |
# 2. I did my changes + made a commit. | |
# 3. Creating the patch | |
git diff dev_branch > short-description-TICKETID-COMMENTID.patch |
drush php-eval "Drupal::configFactory()->getEditable('system.menu.devel')->delete();" |
// If you load a $node or something. | |
kint_require(); | |
\Kint::$maxLevels = 3; | |
kint($node); |