Cloud IDE supports the following PHP tools:
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.
Cloud IDE provides preconfigured Xdebug to help you debug Drupal applications.
Run the acli ide:xdebug-toggle
command to enable or disable Xdebug:
ide:~/project $ acli ide:xdebug-toggle
xDebug PHP extension enabled.
ide:~/project $ acli ide:xdebug-toggle
xDebug PHP extension disabled.
/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
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.
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:
DRUSH_ALLOW_XDEBUG=1 drush pm:list
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:
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
------------------------------------------------------------------------------
Cloud IDE supports Drush 8 for Drupal 7 applications. For the current Drupal version, the best practice is to add Drush to your composer.json
file:
Run the following command:
composer require drush/drush
Cloud IDE supports the following Drupal tests:
Cloud IDE requires multiple environment variables to run Drupal tests, and configures ChromeDriver to establish a 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
To run Drupal tests, you need PHPUnit. To install PHPUnit, pull the Drupal development dependencies:
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)
Run ChromeDriver before you execute Drupal’s functional JavaScript tests.
To launch 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.
&
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.
ide:~/project/docroot (master *) $ pkill chromedriver
[1]+ Terminated chromedriver --port=4444
For more information about Drupal tests, visit Running PHPUnit tests.
If this content did not answer your questions, try searching or contacting our support team for further assistance.
Thu Nov 21 2024 05:48:10 GMT+0000 (Coordinated Universal Time)