Cloud IDE supports Composer 2 to manage PHP dependencies. Composer 2 can be invoked by running the composer command. To view all Composer commands, visit the Composer documentation.
In your Cloud IDE, locate the /home/ide/configs/php/xdebug.ini file.
Edit the file to modify the required settings:
; 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
Important
Do not edit the zend_extension=xdebug.so line.
Restart FastCGI Process Manager (PHP-FPM) to implement the changes:
acli ide:service-restart php
For more information about using Xdebug with Cloud IDE, visit Using Xdebug.
Debugging Drush
In the Cloud IDE menu bar, click Terminal > New Terminal.
Add the DRUSH_ALLOW_XDEBUG=1 environment variable before your Drush command and then run the command to override the default behavior of the Drush launcher.
For example, to debug the pm:list Drush command, add a breakpoint to the pmList method in ./vendor/drush/drush/src/Drupal/Commands/pm/PmCommands.php, and run the following command:
Cloud IDE supports PHP Code Sniffer to help you write quality code. Cloud IDE enforces Drupal best practices with the pre-installed Drupal and DrupalPractice code sniffs.
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:
In the Cloud IDE menu bar, click Terminal > New Terminal.
Invoke the phpcs command and pass the path to the file or the 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
------------------------------------------------------------------------------
To run Drupal tests, you need PHPUnit. To install PHPUnit, pull the Drupal development dependencies:
In the Cloud IDE menu bar, click Terminal > New Terminal.
Run the following command:
composer require --dev drupal/core-dev:*
The following is an example of a test executed within the docroot directory:
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
Run ChromeDriver before you execute Drupal’s functional JavaScript tests.
To launch ChromeDriver:
In the Cloud IDE menu bar, click Terminal > New Terminal.
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.
To allow the process to continue running in the background, pass the & character at the end of the command.
Run functional JavaScript tests after ChromeDriver is launched:
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)
After running functional JavaScript tests, terminate the ChromeDriver process to free up CPU and memory in your IDE.
Cloud IDE supports Composer 2 to manage PHP dependencies. Composer 2 can be invoked by running the composer command. To view all Composer commands, visit the Composer documentation.
In your Cloud IDE, locate the /home/ide/configs/php/xdebug.ini file.
Edit the file to modify the required settings:
; 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
Important
Do not edit the zend_extension=xdebug.so line.
Restart FastCGI Process Manager (PHP-FPM) to implement the changes:
acli ide:service-restart php
For more information about using Xdebug with Cloud IDE, visit Using Xdebug.
Debugging Drush
In the Cloud IDE menu bar, click Terminal > New Terminal.
Add the DRUSH_ALLOW_XDEBUG=1 environment variable before your Drush command and then run the command to override the default behavior of the Drush launcher.
For example, to debug the pm:list Drush command, add a breakpoint to the pmList method in ./vendor/drush/drush/src/Drupal/Commands/pm/PmCommands.php, and run the following command:
Cloud IDE supports PHP Code Sniffer to help you write quality code. Cloud IDE enforces Drupal best practices with the pre-installed Drupal and DrupalPractice code sniffs.
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:
In the Cloud IDE menu bar, click Terminal > New Terminal.
Invoke the phpcs command and pass the path to the file or the 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
------------------------------------------------------------------------------
To run Drupal tests, you need PHPUnit. To install PHPUnit, pull the Drupal development dependencies:
In the Cloud IDE menu bar, click Terminal > New Terminal.
Run the following command:
composer require --dev drupal/core-dev:*
The following is an example of a test executed within the docroot directory:
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
Run ChromeDriver before you execute Drupal’s functional JavaScript tests.
To launch ChromeDriver:
In the Cloud IDE menu bar, click Terminal > New Terminal.
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.
To allow the process to continue running in the background, pass the & character at the end of the command.
Run functional JavaScript tests after ChromeDriver is launched:
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)
After running functional JavaScript tests, terminate the ChromeDriver process to free up CPU and memory in your IDE.