MyBB Community Forums

Full Version: Naming Conventions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want it easier to integrate MyBB with other web apps. To that end, I suggest we pollute the global namespace as little as possible. Everything unique to MyBB should be prefixed (MYBB_ for configuration constants and classes, and mybb_ or mybb for functions outside of classes).

I am making this same suggestion to every other web app software I'm trying to integrate.

The lack of name spaces is one thing I dislike about PHP.
Namespaces will be in PHP6 and I'm really looking forward to be able to use them. However, I don't think it's currently worth the effort for us to prefix everything with mybb_.

Integration with other web apps is nice, but I think you should be able to get around the problem in a different way, e.g. the db_mysql class certainly doesn't need a mybb_ prefix. If you want to integrate MyBB with another script, I don't see why you couldn't just use $db = new db_mysql(); instead of $db = new mybb_db_mysql();
Peter, I was only talking about MyBB specific stuff.

I'm writing an authentication module for phpGedView (an open-source genealogical web app). I thought the easiest way to do this would be to include global.php and functions_user.php from MyBB. Unfortunately, functions.php also gets imported, and get_age() in functions.php conflicts with the PGV function get_age(). Alas, they don't even take the same arguments.

I understand a ton of code has already been written, so I'm just asking that this naming convention be used for new stuff, and we can refactor the old stuff as we have time.
If you're writing an authentication module - I would advise against including any core MyBB files, especially functions.php and global.php.

I would recommend making all database connections yourself and performing the authentication check via your own code.
If MyBB were to impliment Namespaces then everyone using MyBB would have to have PHP6. Which most hosts dont even have PHP5!

Not to mention that php 6 isnt even out yet.

Why does php keep looking more like C++ everyday?
Tikitiki Wrote:Why does php keep looking more like C++ everyday?

Because they did a lousy job at copying Perl???
laie_techie Wrote:To that end, I suggest we pollute the global namespace as little as possible. Everything unique to MyBB should be prefixed (MYBB_ for configuration constants and classes, and mybb_ or mybb for functions outside of classes).
I agree 100%. Big Grin (Not because it's particularly useful to me, but because it just seems like a good, clean coding practice. And I've seen a number of other PHP apps that do it.)

For example, the constant "NO_ONLINE" should really be named "MYBB_NO_ONLINE" Toungue
Tikitiki Wrote:Why does php keep looking more like C++ everyday?
Because C++ is a mature programming language and PHP is based on it?