Keeping PHP source comments outside of the files, where?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Keeping PHP source comments outside of the files, where?

Post by kaisellgren »

Hello,

I would like to keep my comments outside the source files. I'm looking for some handy online solutions, but haven't figured out anything good so far.

Basically instead of having lots of comments in a class I would like to explain the class structure and functionality online so that the comments won't slow down the whole app. I tried running the app with and without comments and the speed difference was 8.9% which I think is enough to consider from moving the comments away from the source code!
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Keeping PHP source comments outside of the files, where?

Post by Eran »

You should definitely not move comments away from your files, unless you never intend for any other developers to maintain your code.
You can do one of two things (or both):
1. Grep your files when they are deployed in production to strip out comments (a simple shell script)
2. Use APC or any other op-code cache. Your scripts are cached in their compiled state, in which comments are no longer a factor. This will have significant performance advantages regardless.
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: Keeping PHP source comments outside of the files, where?

Post by kaisellgren »

pytrin wrote:You should definitely not move comments away from your files, unless you never intend for any other developers to maintain your code.
You can do one of two things (or both):
1. Grep your files when they are deployed in production to strip out comments (a simple shell script)
2. Use APC or any other op-code cache. Your scripts are cached in their compiled state, in which comments are no longer a factor. This will have significant performance advantages regardless.
2. Not possible.
1. I could do that, I'll probably then have two different versions of my software: dev and the regular one. It's just that it adds extra pain to maintain two different systems since I have lots of nasty things going on such as automatic source code updating, etc. So it's a bit pain in the smurf :) Maybe that's the only way to do it well...
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Keeping PHP source comments outside of the files, where?

Post by Eran »

Actually, if you use a versioning system such as SVN, it's easier. You can have the grep script run in a post-commit hook automatically.
Post Reply