I never used Drupal on windows before but now I just wanted to test my module on clean drupal and found out that I just cant use
drupal_add_js(MY_MODULE_ROOT_REL. '\\js\\somejs.js');
// or
drupal_add_js(MY_MODULE_ROOT_REL. '/js/somejs.js');
I defined my custom constants as
/**
* Define root constant. (An absolute path: /home/var/www/)
* This is used to prevent using drupal_get_path() cause __DIR__ is much faster and
* don't use database connection to find out there this module is located.
* @note requires PHP 5.3+
*/
define('MY_MODULE_ROOT', __DIR__);
/**
* Relative path to this module (sites/default/....)
*/
define('MY_MODULE_ROOT_REL', str_replace(DRUPAL_ROOT. DIRECTORY_SEPARATOR, '', MY_MODULE_ROOT));
Disclaimer:
I know that Windows is not platform for develop but I think it is not good if Drupal won't work on windows too.
I know about drupal_get_path() but I don't want to use database connection just to find out the path to my module (I use drupal bootstrap_database layer and only include constant.inc files)
Comments
Comment #1
cadila commentedComment #2
cadila commentedComment #4
cadila commentedComment #5
cadila commentedComment #7
cadila commentedComment #8
cadila commentedFixed patch cause it was in wrong format
Comment #9
cadila commentedComment #10
cadila commentedComment #11
mgiffordThis should get reviewed on a windows machine. Does it matter if it is IIS or Apache?
Comment #12
cadila commentedno it doesn't. I guess it without patch we will fail on both servers. Without patch we only can get it work with Denwer distribution which can simulate Linux paths (it creates virtual disks). I tested on xampp.
Comment #13
mgiffordI think we have to add this functionality in Drupal 8, even though drupal_encode_path() was removed here #2221695: Remove uses of deprecated URL functions since it was replaced with https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Utility!UrlH...
Comment #14
mgiffordComment #15
cadila commentedGreat idea to port this to D8 but actually I'm not familiar with D8 so can't test. Need someone to test latest patch for d8
Comment #16
mgiffordRe-uploading patch for the bots.
Comment #25
catchThe use case in the original report is no longer valid (we use library definitions instead of direct references to js/css files). However the bug report itself might be.
Comment #26
ankithashettyJust updated patch in #16 to fix custom command failures, thanks!
Comment #31
kim.pepperReviewing as part of Bug Smash Initiative. As per the comment in #25 marking this as PMNMI.
Comment #32
smustgrave commentedSince there's been no follow up going to close this one out. If still a bug in D11 please re-open.