Cloud IDE ships with preconfigured tooling that is optimized for Drupal and Node.js development so you can be productive right away. Review the tools installed and supported versions.
Acquia CLI
Acquia CLI is a command-line interface for interacting with the Cloud Platform applications and services.
You can view all Acquia CLI commands here.
Composer
Cloud IDE supports both Composer 1 and 2. Composer 2 is the default and can be invoked by running the composer
command. To invoke Composer 1, run the composer1
command instead.
Note
We encourage you to update your code now so it’s fully compatible with Composer 2. Composer 2 is much faster and has more features than Composer 1.
To view all Composer commands, access Composer documentation.
Xdebug
Xdebug is preconfigured in Cloud IDE. It makes debugging Drupal simpler.
Enabling or disabling Xdebug
Cloud IDE allows you to enable and disable Xdebug with the acli ide:xdebug-toggle
command.
ide:~/project $ acli ide:xdebug-toggle
xDebug PHP extension enabled.
ide:~/project $ acli ide:xdebug-toggle
xDebug PHP extension disabled.
Overriding Xdebug default settings (advanced)
To override the default settings:
- In your Cloud IDE, locate the
/home/ide/configs/php/xdebug.ini
file. Modify any of the following configuration settings but do not uncomment the
;zend_extension=xdebug.so
line manually. Useacli ide:xdebug-toggle
to enable or disable Xdebug as instructed earlier:; Acquia Hosting XDebug defaults ; This file configures the default settings for xdebug. [xdebug] zend_extension=xdebug.so xdebug.mode=develop xdebug.client_host=127.0.0.1 xdebug.client_port=9001 xdebug.max_nesting_level=3000 xdebug.log = /tmp/fcso_debug.log
To apply the changes you made, restart PHP-FPM (FastCGI Process Manager) by running the following command:
acli ide:service-restart php
- For an introduction on using Xdebug with Cloud IDE, follow the best practices outlined in Using Xdebug.
Note
To debug Drush, you must pass the DRUSH_ALLOW_XDEBUG=1
environment variable before your Drush command to override the Drush Launcher default behavior.
For example, to debug the pm:list
command, add a breakpoint to the pmList
method in ./vendor/drush/drush/src/Drupal/Commands/pm/PmCommands.php
, and run the following command in the terminal:
DRUSH_ALLOW_XDEBUG=1 drush pm:list
PHP Code Sniffer
PHP Code Sniffer is an essential part of the Drupal developer toolbox to write quality code. Drupal best practices are automatically enforced in Cloud IDE with the Drupal
and DrupalPractice
code sniffs pre-installed.
ide:~/project (master) $ phpcs -i
The installed coding standards are MySource, PEAR, PSR1, PSR2, PSR12, Squiz, Zend, AcquiaDrupalStrict, AcquiaDrupalTransitional, AcquiaEdge, AcquiaPHP, Drupal, DrupalPractice, PHPCompatibility, VariableAnalysis and SlevomatCodingStandard.
To run PHP Code Sniffer against any supported Drupal file, invoke the phpcs
command and pass the path to the filename or directory.
ide:~/project (master) $ phpcs docroot/core/core.api.php
FILE: /home/ide/project/docroot/core/core.api.php
------------------------------------------------------------------------------
FOUND 13 ERRORS AND 1 WARNING AFFECTING 14 LINES
------------------------------------------------------------------------------
8 | ERROR | [ ] Missing short description in doc comment
459 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
1956 | ERROR | [ ] Type hint "array" missing for $data_types
1973 | ERROR | [ ] Type hint "array" missing for $queues
1992 | ERROR | [ ] Missing parameter type
2039 | ERROR | [x] Doc comment short description must end with a full stop
2045 | ERROR | [ ] Missing parameter type
2047 | ERROR | [ ] Missing parameter type
2068 | ERROR | [ ] Missing parameter type
2122 | ERROR | [ ] Type hint "array" missing for $info
2129 | ERROR | [ ] Missing parameter type
2158 | ERROR | [ ] Type hint "array" missing for $definitions
2232 | ERROR | [ ] Type hint "array" missing for $sync_steps
2254 | ERROR | [ ] Missing parameter type
------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------
Time: 2.74 secs; Memory: 14MB
Drush
Drush 8 is available for Drupal 7 applications. For the current Drupal version, the best practice is to add Drush to your composer.json
file. You can do so with the following command:
composer require drush/drush
PHPUnit
Cloud IDE can run Drupal tests effortlessly. Cloud IDE supports the following Drupal tests:
- Unit tests
- Kernel tests
- Functional tests
- Functional JavaScript tests (with the Chromedriver)
Reviewing environment variables
To run Drupal tests effectively in Cloud IDE, multiple environment variables are required. In particular, Cloud IDE preconfigures the Chromedriver so that it can establish a successful connection with the database.
ide:~/project (master) $ env | grep -E '(TEST|DTT|MINK)'
MINK_DRIVER_ARGS_WEBDRIVER=["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless","--disable-dev-shm-usage"]}}, "http://127.0.0.1:4444"]
DTT_MINK_DRIVER_ARGS=["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless","--disable-dev-shm-usage"]}}, "http://127.0.0.1:4444"]
DTT_BASE_URL=http://127.0.0.1
SIMPLETEST_BASE_URL=http://127.0.0.1
SIMPLETEST_DB=mysql://drupal:[email protected]/drupal
Installing and running PHPUnit
To run Drupal tests, you need PHPUnit. To install PHPUnit, pull the Drupal development dependencies:
composer require --dev drupal/core-dev:*
Post that, you can run tests immediately. For example, you can run a test from within the docroot
directory as follows:
ide:~/project/docroot (master *) $ ../vendor/bin/phpunit -c core --debug --verbose --group=ban
PHPUnit 8.5.15 by Sebastian Bergmann and contributors.
Runtime: PHP 7.4.14
Configuration: /home/ide/project/docroot/core/phpunit.xml.dist
Testing
Test 'Drupal\Tests\ban\Unit\BanMiddlewareTest::testBannedIp' started
Test 'Drupal\Tests\ban\Unit\BanMiddlewareTest::testBannedIp' ended
Test 'Drupal\Tests\ban\Unit\BanMiddlewareTest::testUnbannedIp' started
Test 'Drupal\Tests\ban\Unit\BanMiddlewareTest::testUnbannedIp' ended
Test 'Drupal\Tests\ban\Kernel\Plugin\migrate\source\d7\BlockedIpsTest::testSource with data set #0 (array(array(array(1, '127.0.0.1'))), array(array('127.0.0.1')))' started
Test 'Drupal\Tests\ban\Kernel\Plugin\migrate\source\d7\BlockedIpsTest::testSource with data set #0 (array(array(array(1, '127.0.0.1'))), array(array('127.0.0.1')))' ended
Test 'Drupal\Tests\ban\Kernel\Migrate\d7\MigrateBlockedIpsTest::testBlockedIps' started
Test 'Drupal\Tests\ban\Kernel\Migrate\d7\MigrateBlockedIpsTest::testBlockedIps' ended
Test 'Drupal\Tests\ban\Functional\IpAddressBlockingTest::testIPAddressValidation' started
Test 'Drupal\Tests\ban\Functional\IpAddressBlockingTest::testIPAddressValidation' ended
Time: 17.94 seconds, Memory: 853.00 MB
OK (5 tests, 41 assertions)
Running functional JavaScript tests
Running Drupal’s functional JavaScript tests requires running the Chromedriver. To launch the Chromedriver, run the following command:
ide:~/project/docroot (master *) $ chromedriver --port=4444&
[1] 4838
Starting ChromeDriver 89.0.4389.23 (61b08ee2c50024bab004e48d2b1b083cdbdac579-refs/branch-heads/4389@{#294}) on port 4444
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Note
Passing the &
character at the end of the command allows the process to continue running in the background.
Once the Chromedriver is launched, run any functional JavaScript tests.
ide:~/project/docroot (master *) $ ../vendor/bin/phpunit -c core --debug --verbose core/modules/user/tests/src/FunctionalJavascript
PHPUnit 8.5.15 by Sebastian Bergmann and contributors.
Runtime: PHP 7.4.14
Configuration: /home/ide/project/docroot/core/phpunit.xml.dist
Testing core/modules/user/tests/src/FunctionalJavascript
Test 'Drupal\Tests\user\FunctionalJavascript\RegistrationWithUserFieldsTest::testRegistrationWithUserFields' started
Test 'Drupal\Tests\user\FunctionalJavascript\RegistrationWithUserFieldsTest::testRegistrationWithUserFields' ended
Test 'Drupal\Tests\user\FunctionalJavascript\UserPasswordResetTest::testUserPasswordResetWithAdditionalAjaxForm' started
Test 'Drupal\Tests\user\FunctionalJavascript\UserPasswordResetTest::testUserPasswordResetWithAdditionalAjaxForm' ended
Time: 28.88 seconds, Memory: 8.00 MB
OK (2 tests, 10 assertions)
When you’re done running functional JavaScript tests, kill the Chromedriver process to free up CPU and memory in your IDE.
ide:~/project/docroot (master *) $ pkill chromedriver
[1]+ Terminated chromedriver --port=4444
For more information on Drupal tests, see Running PHPUnit tests.
GitHub CLI
We have documentation for you to successfully clone your Drupal application hosted on GitHub. On top of this, we support the GitHub CLI so you can streamline working with GitHub from the Terminal.
To view all GitHub CLI commands, access GitHub CLI manual.
GitLab CLI
We support the GitLab CLI so that you can seamlessly work with Gitlab from the command line. You can also work with issues, merge requests, and watch running Pipelines directly from your CLI.
To view all GitLab CLI commands, access GitLab CLI.
Node Version Manager (NVM)
Node Version Manager (nvm) is a version manager for Node.js, designed to be installed per user, and invoked per shell.
To install a different version of Node.js, use nvm install
and pass the target version.
ide:~/project (master #) $ nvm install 14.19.1
Downloading and installing node v14.19.1...
Downloading https://nodejs.org/dist/v14.19.1/node-v14.19.1-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v14.19.1 (npm v7.21.1)
To use the newly installed version, use nvm use <version>
.
ide:~/project (master #) $ nvm use 14.19.1
Now using node v14.19.1 (npm v7.21.1)
Note
When the IDE hibernates, all active shell sessions are lost. To permanently set a default version that persists through hibernation, use nvm alias default
instead of nvm use
.
To confirm you are running the target version, type node -v
.
ide:~/project (master #) $ node -v
v18.17.0
Ruby Version Manager (RVM)
The Ruby Version Manager (RVM) is a command-line tool, which allows you to easily install, manage, and work with multiple Ruby environments, from interpreters to sets of gems. It helps with ensuring that all aspects of Ruby are completely contained within user space, strongly encouraging safer, non-root use.
To get a list of existing Ruby versions, use rvm list
.
ide:~/project $ rvm list
=* ruby-2.4.9 [ x86_64 ]
# => - current
# =* - current && default
# * - default
To install a different version of Ruby, you can leverage the rvm install
command and pass your target version.
ide:~/project $ rvm install 2.7.2
Searching for binary rubies, this might take some time.
No binary rubies available for: debian/bullseye_sid/x86_64/ruby-2.7.2.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for debian.
Installing requirements for debian.
.....
Installing required packages: libreadline6-dev...
Requirements installation successful.
Installing Ruby from source to: /home/ide/.rvm/rubies/ruby-2.7.2, this may take a while depending on your cpu(s)...
ruby-2.7.2 - #downloading ruby-2.7.2, this may take a while depending on your connection...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 14.0M 100 14.0M 0 0 27.7M 0 --:--:-- --:--:-- --:--:-- 27.6M
ruby-2.7.2 - #extracting ruby-2.7.2 to /home/ide/.rvm/src/ruby-2.7.2.....
ruby-2.7.2 - #configuring........................................................................
ruby-2.7.2 - #post-configuration..
ruby-2.7.2 - #compiling............................................................................................................
ruby-2.7.2 - #installing..................
ruby-2.7.2 - #making binaries executable...
Installed rubygems 3.1.2 is newer than 3.0.9 provided with installed ruby, skipping installation, use --force to force installation.
ruby-2.7.2 - #gemset created /home/ide/.rvm/gems/ruby-2.7.2@global
ruby-2.7.2 - #importing gemset /home/ide/.rvm/gemsets/global.gems................................................................
ruby-2.7.2 - #generating global wrappers.......
ruby-2.7.2 - #gemset created /home/ide/.rvm/gems/ruby-2.7.2
ruby-2.7.2 - #importing gemsetfile /home/ide/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.7.2 - #generating default wrappers.......
ruby-2.7.2 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.7.2 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
You can observe the new version is now available.
ide:~/project $ rvm list
=* ruby-2.4.9 [ x86_64 ]
ruby-2.7.2 [ x86_64 ]
# => - current
# =* - current && default
# * - default
To switch to the new version, use the following commands.
ide:~/project $ /bin/bash --login
ide:~/project $ rvm use 2.7.2
Using /home/ide/.rvm/gems/ruby-2.7.2
ide:~/project $ rvm list
* ruby-2.4.9 [ x86_64 ]
=> ruby-2.7.2 [ x86_64 ]
# => - current
# =* - current && default
# * - default