Idea? New command listing declared namespaces

9 views
Skip to first unread message

Vincent Férotin

unread,
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:
https://gist.github.com/anonymous/624aeacd85e38254ee9307c5e71ec466
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 php_imports.py 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?

Cheers,

-- Vincent Férotin

Schmunk

unread,
Nov 15, 2016, 8:54:32 AM11/15/16
to compos...@googlegroups.com
You might wanna have a look at https://getcomposer.org/doc/articles/plugins.md

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

Regards,
schmunk
> --
> --
> You received this message because you are subscribed to the "composer-dev" group.
> To post to this group, send email to compos...@googlegroups.com
> To unsubscribe from this group, send email to
> composer-dev...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/composer-dev?hl=en
>
> ---
> 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 composer-dev...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


--
#Contact
sch...@usrbin.de
skype://schmunk23
http://usrbin.de

#Social
http://www.facebook.com/schmunk42
http://twitter.com/schmunk42
https://www.xing.com/profile/Tobias_Munk
http://www.linkedin.com/pub/tobias-munk/20/a67/380

#OpenSource
http://phundament.com/
http://lithron.de/
https://github.com/schmunk42

Vincent Férotin

unread,
Nov 16, 2016, 5:01:10 AM11/16/16
to compos...@googlegroups.com
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?

Regards,

-- 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 https://groups.google.com/d/topic/composer-dev/aSJeuffQPdQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to composer-dev...@googlegroups.com.

Schmunk

unread,
Nov 18, 2016, 8:01:13 AM11/18/16
to compos...@googlegroups.com
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.

Regards,
schmunk

Vincent Férotin

unread,
Nov 21, 2016, 5:00:32 AM11/21/16
to compos...@googlegroups.com
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 ;-)

Regards,

-- Vincent
Reply all
Reply to author
Forward
0 new messages