Quote:
quote:Originally posted by azharmateen
1. Is there any standard Coding Conventions available, which a large number of developers are using?
|
There isn't any one single "coding convention" for PHP -- when you think about it, there isn't a single accepted convention for *any* language. Style debates are older and more fervently fought than the old "Vi vs. Emacs" debate.
For a decent start, though, I suggest you read through the PEAR coding standard:
http://pear.php.net/
Quote:
quote:Originally posted by azharmateen
2. Any information assisting as "Best Practices" in PHP applicationâs architecture? Especially, for designing multi-lingual applications, security, maintenance, back-up and mirror sites.
|
Well, the best place to start learning about security and PHP is to read the PHP manual:
http://www.php.net/security
Designing multi-lingual applications in PHP is similar to designing them in any language -- typically, you'd never output text to the user as a standalone string; you'd have one or more resource files containing ALL of the strings to be displayed to the user, and display the variable corresponding to that string.
For example, here is an example of a multilingual "Hello, world";
[code]
<?php // config.inc.php
$default_lang = 'en';
$language_codes = array('en', // English
'es', // Spanish
'fr'); // French
function set_lang()
{
if(isset($_GET['lang']) &&
in_array($_GET['lang'], $GLOBALS['language_codes']))
{
$GLOBALS['lang'] = $_GET['lang'];
}
else
{
$GLOBALS['lang'] = $GLOBALS['default_lang'];
}
}
set_lang();
require_once("lang.{$lang}.inc.php"); // include proper resource file
?>
<?php // lang.en.inc.php
$hello_str = "Hello, world!";
$submit_str = "Submit";
$language_names = array("en" => "English",
"es" => "Spanish",
"fr" => "French");
?>
<?php // lang.es.inc.php
$hello_str = "¡Hola, el mundo!";
$submit_str = "Sométase";
$language_names = array("en" => "Inglés",
"es" => "Español",
"fr" => "Francés");
?>
<?php // lang.fr.inc.php
$hello_str = "Bonjour, le monde!";
$submit_str = "Soumettre";
$language_names = array("en" => "Anglais",
"es" => "Espagnol",
"fr" => "Français");
?>
<?php // main.php
require_once('config.inc.php');
// this require_once() call sets the appropriate language
// and includes the proper resource file.
// The main application never outputs anything to the user,
// it only outputs string variables defined in the resource files.
echo $hello_str;
echo "\n"; // HTML can be output by the application,
// since it's not language-dependent.
// we'll include a short form to let the user change languages.
echo "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"get\">\n";
echo " <select name=\"lang\">\n";
foreach($language_codes as $lang_key)
{
// our form will preselect the current language
$selected = ($lang == $lang_key)? " selected=\"\"" : "";
echo " <option value=\"{$lang_key}\"{$selected}>"
. $language_names[$lang_key]
. "</option>\n";
}
echo " </select>\n";
echo " <input type=\"submit\" value=\"{$submit_str}\" />\n";
echo "</form>\n";
?>
Maintenance and backup -- that's more an server admin issue, not a programming one. Same thing with mirror sites. For database-driven sites, many sites use the same database server for data but use multiple web server machines to split the load of all the incoming requests and PHP processing.
Quote:
quote:Originally posted by azharmateen
3. Online resources pointing the ready-to-use source code and libraries.
|
Search on google for PHP. There are a lot of code repositories and user communities out there. PHP has a bunch of links on it's home page for PHP resources and communities.
http://www.php.net/
Also try
http://www.phpbuilder.com/,
http://www.hotscripts.com/, etc.
Quote:
quote:Originally posted by azharmateen
4. Development checklists, which can help to prevent the general mistakes and common errors. Similarly, application-testing checklists for ensuring the tasks are completed successfully.
|
What's there to say here? Your development and testing checklists are nothing more than the questions "Did I finish the job I said I'd do? Does it work?"
When testing web applications, there's more than just functional testing. You need to test for erroneous user input (form validation) and load testing as well. Load testing is stressing the web server with a LOT of requests to see how the application holds up under high-traffic situations. For most people, this isn't a priority, but if an application is written inefficiently, the bottlenecks will become apparent.
Most bottlenecks in PHP applications are due to inefficient SQL queries, or queries that return wayyy too much data, only to be filtered in PHP, poor loop logic, etc.
Quote:
quote:Originally posted by azharmateen
5. Development and development assisting tools.
|
There are a few PHP IDEs out there, some with functional debuggers now. I don't use these, personally, but they're there. Search for "PHP IDE" in google and see what you dig up. I know that Zend (the PHP people) have their own, which is supposed to be pretty slick.
Take care,
Nik
http://www.bigaction.org/