SitePoint Sponsor |
|
User Tag List
Results 1 to 21 of 21
-
May 13, 2001, 03:20 #1
- Join Date
- Mar 2001
- Location
- Melbourne, Australia
- Posts
- 1,039
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi All,
I'm a web developer myself, but looking to sub-contract some work out to others (sorry - I'm not looking for applicants!).
What I want to get hold of, or develop myself, is a set of guidelines/standards that I can hand to some who does work for me and say "right, this is the framework within which I'd like you to work". It would be a general document of web development standards such which folder structure to use on the web server, which file extensions to use (eg. .php and not .php4...), whether to use CSS or not, which browsers to be compatible with, which php files I'd expect to see (eg. common.inc, functions.inc), etc.
In other words, it would attempt to establish a project-independent (as far as that is possible) web site development framework. Naturally, it would be a living document, subject to improvement based on accumulated experience. Far from being an attempt to 'tell a programmer how to program', the idea is to assist in the process of managing multiple programmers/developers collaborating on the same web development project at the same time.
Does anyone know of such a document that I could use as a template to build my own? Or perhaps you'd like to post some suggested basic guidelines of your own to this thread? Maybe you have other advice/ideas you'd like to share on the subject of collaborative web development?
Thanks very much.
-
May 14, 2001, 13:24 #2
- Join Date
- Mar 2001
- Location
- Southern California, USA
- Posts
- 1,181
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Some suggestions:
- Proper use of indenting 2 or 3 spaces and the use of curly braces. I prefer
While (...)
{
....
}
- Error handlings in one format that you all agree with.
- Functions should begin with a verb. For example: use insert_record() instead of record_insert();
- Comments use - where to put in a function, a script, or next to a strange variable.
- If a file is pure html file, I'd like to append with htm such as htm_login_form.htm so that we can recognize it quick.
- Do not use Upper case letter in a variable such as $validAddress or $Validaddress
Any other suggestions?
JohnLast edited by johnn; May 14, 2001 at 13:27.
-
May 14, 2001, 13:44 #3
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Unfortunately with a language like PHP which has a such a loose standard, it will be hard to convince others to abide by your ways. It is fine to say you should keep db stuff in an included file or you should use .php extensions but with stuff like where to put curly brackets, its really a personal preference and really has no effect on the code. With that note I prefer
PHP Code:function make_upper($str) {
return strtoupper($str);
}
PHP Code:function make_upper($str)
{
return strtoupper($str);
}
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
May 14, 2001, 14:25 #4
- Join Date
- Oct 2000
- Location
- Austin, TX
- Posts
- 1,438
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yeah I indent that way too. And not allowing upper case characters in variable names is retarded. I prefer formatting function names and variables with a oneTwo naming scheme, and there is no reason to mandate capitalization. So I'd do:
PHP Code:function makeUpper($myStr){
return strtoupper($myStr);
}
/include: all included files
/css: style sheets
/scripts: javascript
/images: images
/secure: .htaccess-protected directory that cannot be accessed externally
/output: any text-file output generated by scripts
/log: error logs
-
May 14, 2001, 14:36 #5
- Join Date
- Jul 1999
- Location
- Chicago
- Posts
- 2,629
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Personally I prefer code like this:
PHP Code:# * Function: make_uppercase
# Description: Take a string, $str, and return
# it, completely in capital letters
function make_uppercase($str) {
return strtoupper($str); # comment (note 8-space tab on this line)
}
I use the following comment types in my code:PHP Code:# * function
# & what the whole file does
# $ last time modified (filled in by CVS)
# normal comment
# % information about stuff that needs to be added
/index.pl - most of the stuff is passed through the querystring (no need for separate files)
/res/ - Short for "resources"
-----/img/ - Images
-----/inc/ - Include files
-----/css/ - CSS files
-----/tmpl/ - Templates
-----/logs/ - Logs
/admin/index.pl - For admin tasks
Other people tend to catch on to my commenting style pretty quickly. That's pretty much the only non-ordinary thing I do in my code.
-
May 14, 2001, 21:34 #6
- Join Date
- Mar 2001
- Posts
- 3,537
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
How do you create directory structures on your local pc? I have all the latest versions of php/mysql/apache on win98, and I tried creating a subdirectory in the document root and php/apache couldn't see those files, so all my files are just mixed together.
Also, should every function and include be in a separate file? If you combine several functions in one file, then when you include the file, you might include some functions you aren't going to use, so that would slow down your script wouldn't it?
I gravitated to this style:
Code:function make_upper($str) { return strtoupper($str); }
lol...great quotes in your signature qslack.Last edited by 7stud; May 14, 2001 at 21:42.
-
May 14, 2001, 21:44 #7
- Join Date
- Jun 2000
- Location
- Sydney, Australia
- Posts
- 3,798
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
A great question. My main task today is to ponder the architecture of a suite of web applications I am putting together for a project. Most will be written by me and some are pre-existing scripts.
There is a interesting methodology for Cold Fusion application architecture called fusebox www.fusebox.com There is also an article (with mixed reviews in the user comments) at www.phpbuilder on adapting the methodology for PHP. There are a few other articles on architecture at www.phpbuilder.com/columns/ that may be of interest.
Here is another methodology http://www.zend.com/zend/art/free-energy.php .
As for coding standards, I was made aware of the PEAR standards for PHP in a post here by Phillip Olsen. Here is the link http://php.net/manual/en/pear.standards.php
Best of luck
BTW - I can't get too excited about where the curly braces go around blocks of code. However, blocked code should always be indented within a control structure. My university has three acceptable ways of placing the curly braces around control structures in its coding standard.Last edited by freakysid; May 14, 2001 at 21:59.
-
May 14, 2001, 22:54 #8
- Join Date
- Mar 2001
- Location
- Melbourne, Australia
- Posts
- 1,039
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How do you create directory structures on your local pc? I have all the latest versions of php/mysql/apache on win98, and I tried creating a subdirectory in the document root and php/apache couldn't see those files, so all my files are just mixed together.
C:\apache\htdocs\
and it's here that I create all my subfolders for the web site projects I work on. For example, if I'm working on xyz.com's web site, then I'll create the folder:
C:\apache\htdocs\xyz.com\
In the above folder I'll stick all the orginal image files and stuff that I don't want to be on the web server, and then in this folder:
C:\apache\htdocs\xyz.com\www\
I stick all the files that will be ftp'd to the web server (including the use of sub-folders such as \images\, \include\, etc.
If you've installed and configured apache/php/mysql correctly, then you should just be able to point your browser to:
http://localhost/xyz.com/www/
to see your web site in all it's glory.
If you don't see it, then there are heaps of other threads on this forum and others to help you to get it right.
The point is that I need to have my local machine (running Windows/Apache) configured as best I can so that I can copy the whole lot up to my remote web server (UNIX/Apache) without have to make any special adjustments to any part of the code in order to get it working properly.
The way I've just described above is the way that works for me, but there may be a better way (as there normally is in this business).
Also, should every function and include be in a separate file? If you combine several functions in one file, then when you include the file, you might include some functions you aren't going to use, so that would slow down your script wouldn't it?
I gravitated to this style:
Code:function make_upper($str) { return strtoupper($str); }
-
May 14, 2001, 23:23 #9
- Join Date
- Mar 2001
- Location
- Melbourne, Australia
- Posts
- 1,039
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
A couple of points to add...
All my files that are explicitly for including in other scripts I give a '.inc' extension, and then I include this .htaccess file in the www folder of my remote apache web server:
AddType application/x-httpd-php .htm
<Files ~ "\.inc$">
Order allow,deny
Deny from all
</Files>
This serves two functions:
1. Allows me to have name HTML web pages with php inside with a '.htm' extension as opposed to '.php'. Why? Because I believe (but don't have scientific proof) that web pages named with a .htm/.html extensions are _generally_ more search engine friendly than other web page extensions such as .php, .asp, .cfn, etc.
2. Denies web browser access to anyone trying to view my '.inc' files.
-
May 15, 2001, 03:51 #10
- Join Date
- Jul 2000
- Location
- Perth Australia
- Posts
- 1,717
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I can't get too excited about where the curly braces go around blocks of code.
-
May 17, 2001, 07:19 #11
- Join Date
- Nov 2000
- Location
- Belgium
- Posts
- 102
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I prefer to use
function make_upper($str)
{return strtoupper($str);
}
This way you can see clearly and fast to what function the section belongs.
Well it's just an idea, but for me I think it's a good one
-
May 17, 2001, 08:07 #12
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I keep it like this (pay no attention to the actual conditionals, they're dummies):
Code:if ($var) { } else if ($var) { } else { }
Code:if ($var) { } else if ($var) { } else { }
Code:require("global.php"); if ($var) { print "Hey"; } else { print "Whoa"; }
-
May 17, 2001, 08:08 #13
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by DreamDevil
I prefer to use
function make_upper($str)
{return strtoupper($str);
}
This way you can see clearly and fast to what function the section belongs.
Well it's just an idea, but for me I think it's a good one
$text = make_upper($text);
...isn't any quicker than:
$text = strtoupper($text);
I figure it's probably just a filler function -- just checking.
-
May 17, 2001, 14:33 #14
- Join Date
- Oct 2000
- Location
- Austin, TX
- Posts
- 1,438
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Actually, running strtoupper() from another function is faster.
-
May 17, 2001, 14:50 #15
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Really? How so?
-
May 17, 2001, 14:52 #16
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I would like to know how you came about that rationale as well
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
May 17, 2001, 14:53 #17
- Join Date
- Oct 2000
- Location
- Austin, TX
- Posts
- 1,438
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Sarcasm...
-
May 17, 2001, 14:55 #18
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You shouldn't sound so confident in your theories if they are just sarcasm.
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
May 17, 2001, 14:57 #19
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
No big deal -- just tack a smilie face at the end and we might figure it out
-
May 17, 2001, 16:14 #20
- Join Date
- Jan 2001
- Location
- buried in the database shell (Washington, DC)
- Posts
- 1,107
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I try and stick to this convention:
PHP Code:if( $bob ) {
do something
} else {
do something else
} // end if
while( $joe_wallet >= 0 ) {
$joe_wallet->spend( 1 );
} // end while
$bob[ 1 ] = str_to_downer_roger_niner( 43 );
//////////////////
// Function eat_my_shorts
// Recieves: $shorts -- pair of sorts to eat (array)
// $teeth -- number of teeth to bite
// Returns: $success -- true or false value determining if the user ate the $shorts
//////////////////
function eat_my_shorts( $shorts, $teeth = 20 ) {
if( $shorts->waistband > 35 ) {
$success = 0;
} else if( $shorts->waistband < 30 ) {
$success = 1;
} // end if
if( $success ) {
stuff;
} // end if
return $success;
} // end function eat_my_shorts
// other functions
Last edited by MattR; May 17, 2001 at 16:18.
Matt - Sybase DBA / PHP fanatic
Sybase/MySQL/Oracle | I don't like MySQL
Download Sybase | DBForums.com - for all your RDBMS talk
-
May 18, 2001, 11:21 #21
- Join Date
- Mar 2001
- Location
- Washington State
- Posts
- 70
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Aside from the pear standards (as mentioned above but deserves another look :-) :
http://www.php.net/manual/en/pear.standards.php
Be sure to check out the two 'php hackers paradise' articles :
http://www.e-gineer.com/articles/php...paradise.phtml
http://www.e-gineer.com/articles/php...evisited.phtml
Also, one might be interested in this three part series :
http://zend.com/zend/art/mistake.php
As well as the various slide presentations shown at various PHP confrences :
http://conf.php.net/
Also, freakysid eluded to the related phpbuilder articles, be sure to check them out too.
Bookmarks