Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Matthew Carter Newsgroups: comp.lang.php Subject: Re: PHP boilerplate to appear at the top of any program Date: Mon, 21 Dec 2015 21:57:44 -0500 Organization: Ahungry (http://ahungry.com) Lines: 49 Message-ID: <87a8p3kx5j.fsf@ahungry.com> References: <87io3rkxyr.fsf@ahungry.com> <87egefkxn5.fsf@ahungry.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="7c986cd4736462de309a749b207746fe"; logging-data="7365"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+BNC2AYzIsjTDdw2xmQABZ" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:8G9D5/G0RpvoufYpno2fYvpKyn8= sha1:3fQlSQt3C0t4TvQFWSIwtPfYLII= Xref: csiph.com comp.lang.php:15952 Jerry Stuckle writes: > On 12/21/2015 9:47 PM, Matthew Carter wrote: >> Matthew Carter writes: >> >>> Jerry Stuckle writes: >>> >>>> On 12/21/2015 5:53 PM, Daniel Pitts wrote: >>>> >>>> Why do you use namespaces? They are very useful in languages like C++, >>>> but pretty worthless in PHP. >>>> >>>> As I said before, I do use it for my own classes, and things like >>>> userids/passwords, which I store outside of my DOCUMENT_ROOT. >>>> >>>> But I have never found a need for namespaces in PHP (unlike C++). >>> >>> http://www.php-fig.org/psr/psr-4/ >> >> Obviously the reason for that is: >> >> https://packagist.org/statistics >> >> To tap into the 80k available packages (almost half a million various >> versions for whatever your requirements may be on the environment). >> >> Without using namespaces, you can't really contribute or make use of >> anything off composer. >> > > How about specific examples? How many of those packages do you actually > use? And how many of them define namespaces? And finally, how many > times have you found a conflict where you need namespaces? > > For me, the answer to the last one is zero. In various capacities, I've probably used about 20 to 30 of them (and they all have their own chained dependencies etc.). You can't use them without namespaces (or write your own internal composer installable dependencies), as all the loading composer does is via the PSR4 autoloading. After getting used to it, it's much easier than past methods of installing community packages/libraries. -- Matthew Carter (m@ahungry.com) http://ahungry.com