Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php best practices, share your skills with me :)

Status
Not open for further replies.

LinuXelite

Programmer
Jun 21, 2002
150
CA
Hi

I start a whole new project. I want to reconsider my way of designing web application.

First, I'll use only XHTML/CSS. I'll drop HTML. I'll use PHP5 because the project will take MONTHS to developt so I'll be ready when PHP5 will be release for production server. This means that I will use OO programming almost for every functionnalities (xml service, orders, cart, auth, etc...)

Secondo, I'm looking for a way to do this:

- multi-language support (best solutions?);
- No hard-coded SQL (POST+SQL insert, select, etc...);
- Modules with ACLs that I can remove/add;

I want to code like Egroupware did (but this one is too complex, I dont understand their logic...)

#1 Multi-language

What do you use? Right now I use this method:

lang_top.inc.php
$TOP_MENU1['en'] = 'My office';
$TOP_MENU1['fr'] = 'Tableau de bord';

and then I call <?php echo $TOP_MENU4[$lang]?>

Is there a better way?

#2 FORMS AND SQL

Right now, I design a form like that:
<form action=&quot;$PHP_SELF&quot; method=post...etc>

In the top of my page, I do something like:

switch ($mode) {
&quot;add&quot;: $sSQL=&quot;INSERT INTO table VALUES $_POST['']....;
&quot;mod&quot;: $sSQL=&quot;UPDATE....&quot;;
&quot;del&quot;: $sSQL=&quot;DELETE from table where id...&quot;;
default: $sSQL = &quot;SELECT from table where id=$_GET[id]&quot;;
}

well.. you get the idea... each form is long and hard to code and update.

I want to design a form once, that can insert, delete, update, select fields from a tables. I can program an object and pass an Array.. I dont know... what is the best pratice with PHP/MySQL?


#3 Modules

I want a system that can add/remove modules for each customer. I want exactly what egroupware uses. Well I have a good idea how do to this but if you use a simple system for that, tell me how you do this :).

Conclustion: I want a system that is powerfull, FAST, easy to update with a lot of code reutilisation (thanks to OOP).

Thank you for sharing your thoughs on this topic!

Frank,
 
Hum..

Well there are hundred of projects out there that use great libs. But they dont use xhtml/xml and I'll not use HTML in my web page.

has begin to use XML to store webformm and SQL query. This is a great idea! However, I can't really use their code because its too slow!! I've try the zend optimezer... I gain 14% more performance. With Zend Accelerator, I think I could get 300% more speed but this product is 2000$, too much for me ;o)

oscommerce.com has a great lib to hadle SQL queries and form.

But Its very difficult to use it into my apps. I think I'll have to build my own framework that fits my needs. I'll re-use some code from many OpenSource projects. Dont worry, its going to be release under GLP on my website.

Frank,
 
Hi LinuxElite!

I know it's been a year, but i'm curious how you went with your best practice oo php app.

I'm in a very similar situation to you a year ago, and i'd be very curious to hear how you went and what practices you followed, as well as the techncial details of how you achieved your goals.

----------------------------------------------------------------------------
The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.
 
Hi

We've made our project.

We used Linux, PHP5, mysqli and Mysql 4.1. We have 290 classes.

We have a SOAP system, we do mail merging OpenOffice Document and WordML file within PHP, we have a XUL interface (for those who uses Firefox), a SyncML Server implementation and a complete report generation class.

The project is fast and the solution is scalable. I installed the Zend Performance suite and I store the session in RAMDISK (/tmp/sessions on /tmp/sessions type tmpfs (rw,bind))

The typical form looks like this:

require_one(commonc.in.php);

$myTop = new HTML_Top();

$myInput1 = new HTML_TextBox('dbname', 'dbfield);
$myInput1->SetWith('200px');
$myInput1->SetLabelWith('65px');

$myFrame = new HTML_Frame(LABEL);
$myFrame->AddControl($myInput1);

$myForm = new Form('dbname','formname');
$myForm->AddControl($myFrame);

$myTop->Show();
$myForm->Show();
$myBottom = new Bottom()
$myBottom->Show();


Well this is just an example. Our FrameWork supports a lot more features and is quite complete. I don't remember when I did SQL or HTML. We have a SQLQuery class for that and we manage fk from a db dictionnary.

In conclusion, I was not sure if PHP could meet the requirement of such a big project. I have to say that PHP4 is not ready for an entreprise application and never will be.

However, I think PHP5 is ready and it works. In our case, the most important thing is not PHP but the fact that we acheived our goal and that it is fast and stable.

Frank,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top