tropo / tropo-webapi-php

A set of PHP classes for working with the Voxeo Tropo WebAPI
MIT License
94 stars 50 forks source link

Class name conflicts #4

Open ahutchings opened 13 years ago

ahutchings commented 13 years ago

When using the Tropo PHP library with other packages, it is likely that some class names will conflict. Two classes included with the library have common names, but are not used: Format and Date. Would it be possible for these to be namespaced (e.g. TropoFormat or real namespaces) or removed?

mheadd commented 13 years ago

Actually, those classes were meant to be used by developers that write WebAPI apps in PHP, to help format readback of text-to-speech content with SSML.

Your point is well taken, and I'm mulling over a couple of different ways to address it.

One option you always have is to fork this repo and remove them form your copy. You should be able to merge any future changes into your own fork should you want to stay current with future changes.

mimecine commented 13 years ago

I second the namespacing issues, many names are too common: Session, Result etc. Having everything namespaced Tropo would definitely make life easier if you ever need to combine the WebAPI with other frameworks... I guess one could use proper php namespacing, but that would bar people to use it with php older than 5.3.0 (and to be honest, php namespacing is pretty ugly and still a bit thorny I feel)

mheadd commented 13 years ago

Thanks for the comment. Still trying to decide on the best way to do this.

Looking for more developer input, also considering using a separate branch to support proper PHP namespacing to address this.

kcivey commented 13 years ago

A "Tropo" prefix on all the classes seems like it would work. I agree with mimecine that using PHP namespaces could be limiting (and is ugly, though I suppose we have to get used to it eventually).

Daniel15 commented 13 years ago

Since the requirements already state "PHP 5.3.0 or greater", you can just use PHP namespaces. A simple approach is to stick everything into a "Tropo" namespace.

Daniel15 commented 13 years ago

Oops, I didn't read through all the comments - Seems namespaces were already mentioned. They're the proper approach, and people should be on PHP 5.3 anyways. PHP 5.2 is deprecated.

acoulton commented 12 years ago

I agree, PHP namespaces are the best way to handle this (and pretty much required if you want to use this library with many of the common frameworks - classes like Session are also pretty commonly used).

I've done it for myself anyway, and created a pull at https://github.com/tropo/tropo-webapi-php/pull/28

mheadd commented 12 years ago

Thanks!

Will work to pull this into a separate PHP 5.3 specific branch for this lib.

djbusby commented 11 years ago

+1 for PHP Namespaces, all vendors should be doing this, thanks to acoulton the patch