Idea? New command listing declared namespaces

Skip to first unread message

Vincent Férotin

Nov 15, 2016, 8:50:51 AM11/15/16
to composer-dev
Hi, composer-dev list!

In order to move some existing PHP projects to Composer, I made a small script
that automatically parses PHP files of each project, collects and lists
their declared used imports. That greatly simplifies adding Composer requirement to these projects,
at least for my basic need. Could such a simple idea be useful for other users?
And in this case, could it be implemented as a new Composer subcommand,
e.g. ``composer list-imports``?

Here's the current script:
I'm sorry it's in Python 3 so far...
but I'm pretty sure it could easily be translated in PHP ;-)

Call to software is done through command-line:

    $ python3 MODULE_PATH

where `MODULE_PATH` is a placeholder for either a PHP filepath,
or a PHP project directory.

The script prints to standard output the list of collected declared namespaces,
without checking if their are actually used or not
(for this case, PHP linters are better tools).

What do you think about that?


-- Vincent Férotin


Nov 15, 2016, 8:54:32 AM11/15/16
You might wanna have a look at

From a first read, all points you mentioned should be possible.

> --
> --
> You received this message because you are subscribed to the "composer-dev" group.
> To post to this group, send email to
> To unsubscribe from this group, send email to
> For more options, visit this group at
> ---
> You received this message because you are subscribed to the Google Groups "composer-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> For more options, visit




Vincent Férotin

Nov 16, 2016, 5:01:10 AM11/16/16
Thanks, schmunk, for pointing a part of Composer doc I had never red so far!
But my post was not about asking how I could re-implement in PHP the
Python script,
so let's clarifying it a bit... (or perhaps I misunderstood your answer?)

This script works fine for my first and basic use case
-- I have no intention to change it: it has succeeded in its goal.
The point of my post was to purpose to Composer devs the idea of
implementing its feature
directly in Composer, if users find this util -- what I could not
judge for my point of view.

So, do you guys think it should be desirable?


-- Vincent Férotin
> You received this message because you are subscribed to a topic in the Google Groups "composer-dev" group.
> To unsubscribe from this topic, visit
> To unsubscribe from this group and all its topics, send an email to


Nov 18, 2016, 8:01:13 AM11/18/16
Hi Vincent,

I was just pointing to the docs, because I think it can easily be implemented as a plugin.
I don’t think it’s needed for the core, but I am not a maintainer, so these are just my two cents.


Vincent Férotin

Nov 21, 2016, 5:00:32 AM11/21/16
Hi schmunk,

You're right: a first PHP implementation could fall in a Composer plugin.
Regarding reactions here to the idea proposal, this does not seem to
be as relevant ;-)


-- Vincent
Reply all
Reply to author
0 new messages