Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Using ede-php-autoload with PHP-mode

Aperta
#256 14 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
emacs-lisp, php
Ambito
tooling

Direzione di ricerca

Inizia esaminando i punti di integrazione di PHP-mode mostrati nell’issue, in particolare php-mode-hook, php-mode-map e gli esempi di utilizzo di ede-php-autoload. L’issue non definisce una modifica concreta né dei test; il lavoro è completato solo dopo aver concordato il comportamento di integrazione desiderato e i controlli di accettazione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

ede-php-autoload is a fantastic package that enables Emacs to understand the dependencies of PHP projects, the most immediate benefit of this is that Emacs can translate class names into files, for example allowing you to jump to the definition of a third-party package with the flick of a button.

The package provides PSR-0 and PSR-4 autoload capabilities to the SemanticDB Emacs subsystem and it can be either used as part of the Semantic parsing system, or with some customisation as a standalone package that doesn't require semantic-mode to be active on your php buffers.

Since ede-php-autoload is by nature designed to work in conjunction with semantic PHP parsers, here's a couple of implementations that's worth knowing about:

I personally am using ede-php-autoload without semantic-mode so I've hacked a function that uses it to jump to the declaration of a class imported with use.

(defun ofc/tags-find-at-point ()
  "Finds the definitions of the symbol at point using a tag file."
  (interactive)
  (xref-find-definitions (thing-at-point 'sexp)))

(defun ofc/visit-class-file-at-point ()
  "Maps a FQN into a file name using PHP autoload resolution."
  (interactive)
  (let* ((class-name (replace-regexp-in-string "^\\\\" "" (thing-at-point 'sexp)))
         (class-file (ede-php-autoload-find-class-def-file (ede-current-project) class-name)))
    (when class-file
      (xref-push-marker-stack)
      (find-file class-file))))

(defun ofc/php-tags-find-at-point ()
  "When called on a FQN, it resolves its name and jumps to the file where it's defined.
When called on anything else it forwards the call to a tag search function."
  (interactive)
  (unless (ofc/visit-class-file-at-point)
    (ofc/tags-find-at-point)))

(global-ede-mode 1)
(add-hook 'php-mode-hook #'ede-php-autoload-mode)
(define-key php-mode-map (kbd "M-.") 'ofc/php-tags-find-at-point)

I would be interested in knowing how @jorissteyn and @stevenremot are using it.

Lingua principale
Emacs Lisp
Stelle
602
Fork
117
Merge medio
12h 54m
PR unite (30g)
3

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di emacs-php/php-mode

Tutte le issue di emacs-php/php-mode

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.