Skip to content

[RFC] Create common DomCrawlerInterface #35873

Closed
@webignition

Description

@webignition

I maintain a library that has a dependency on symfony/panther. The library needs to look around in the DOM of a web page. For this, the panther crawler is perfect.

Having a dependency on symfony/panther requires me to update the library in advance of updating other dependent projects/libraries. Hardly a difficult task but still one that is necessary and which could be avoided.

If both the panther crawler and the dom-crawler crawler implemented a common DomCrawlerInterface my library would no longer be dependent on panther and could instead be implemented against the interface. Implementing against an interface is always good, this is likely beneficial in other cases.

I'm putting this out for comments and feedback as creating such an interface requires updates to symfony/panther and symfony/dom-crawler in addition to the creation of an interface held independently of the two (not sure where that would/should live).

Some initial thoughts:

  • a single interface would not suffice
  • the panther crawler throws exceptions for a variety of methods that the dom-crawler crawler implements
  • there are methods common to both crawlers, perhaps these could form DomCrawlerInterface?
  • most methods that the dom-crawler crawler implements and which throw exceptions in the panther crawler relate to mutating the DOM (adding nodes and so on), perhaps these could form DomMutatorInterface and be implemented only in the dom-crawler crawler?
  • where could the common interface live? It can't be within either the symfony/panther or symfony/dom-crawler repos.

Possible development plan:

  • create interfaces (no idea where)
  • update dom-crawler crawler to implement interfaces
  • update panther crawler to implement interface

Decisions to be made:

  • is this is even a good idea?
  • what to name the interfaces and what method signatures to include
  • where should the interfaces live?

I'm happy to take ownership and implement the changes. It seems silly to attempt that without some consensus on if that is necessary and, if so, what needs to be created.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DomCrawlerRFCRFC = Request For Comments (proposals about features that you want to be discussed)Stalled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions