diff --git a/Cask b/Cask index 98e06c3c..cb694f8a 100644 --- a/Cask +++ b/Cask @@ -9,4 +9,5 @@ (development (depends-on "pkg-info") + (depends-on "projectile") (depends-on "shut-up")) diff --git a/php-project.el b/php-project.el index 6029238e..08cd4928 100644 --- a/php-project.el +++ b/php-project.el @@ -68,6 +68,7 @@ ;;; Code: (require 'cl-lib) +(require 'projectile nil t) ;; Constants (defconst php-project-composer-autoloader "vendor/autoload.php") @@ -84,6 +85,12 @@ :tag "PHP Project Auto Detect Etags File" :group 'php-project :type 'boolean) + +(defcustom php-project-use-projectile-to-detect-root nil + "If `T' and projectile-mode is activated, use Projectile for root detection." + :tag "PHP Project Use Projectile To Detect Root" + :group 'php-project + :type 'boolean) ;; Variables (defvar php-project-available-root-files @@ -269,6 +276,15 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.") "Return path to current PHP project." (if (and (stringp php-project-root) (file-directory-p php-project-root)) php-project-root + (php-project--detect-root-dir))) + +(defun php-project--detect-root-dir () + "Return detected project root." + (if (and php-project-use-projectile-to-detect-root + (bound-and-true-p projectile-mode) + (fboundp 'projectile-project-root) + (projectile-project-root)) + (projectile-project-root default-directory) (let ((detect-method (cond ((stringp php-project-root) (list php-project-root))