Page 1 of 1
is this a fancy way of writing PHP code??
Posted: Thu Jun 19, 2008 4:36 am
by claws
Hello,
I'm using PHP CSV IMPORTER. Its very nice. But, I had to customize it for my purpose. I opened the source and surprised.
here is the link to download.
can some one please have a look at it and say, what is it? Is it some kind of "Design Pattern"? If so, which one?
But, what ever it is, I'm very impressed with that style of coding. Can some post some pointers to learn that way of coding?
Thanks.
Re: is this a fancy way of writing PHP code??
Posted: Thu Jun 19, 2008 4:49 am
by onion2k
Looks like an MVC pattern with a template system of some sort to me.
Re: is this a fancy way of writing PHP code??
Posted: Thu Jun 19, 2008 4:50 am
by jmut
nothing special I see there. what exactly is that you like?
Re: is this a fancy way of writing PHP code??
Posted: Thu Jun 19, 2008 11:44 am
by claws
jmut wrote:nothing special I see there. what exactly is that you like?
Actually I never designed a website like that. I write both HTML, PHP, (and any thing and everything in only single file). for example If i need to write a script for user registration.
1. html form
2. handling submitted data
3. server side checking and prompting the user for resubmission of form.
4. storing in database.
I write all these in single script "register.php" or modulize these into 4 files each handling the task as listed above. This is the way, I write any script.
I've been using PHP for 3 years. But, I'm still using the same style of coding which I learnt in the beginning. My style looks completely un professional. Its been 3 years, I want to move on.
Seriously, Though I used the phrase "Design Pattern". I don't know what it is? I never bothered about it because I didn't felt the requirement of something more.
I hope now you might have understood my standard. Now, based on this. Please suggest me.
1. How can I write some professional code. (Some thing like shown in PHP CSV IMPORTER. If you feel something else is better than this, please suggest.]
2. It would be lot of help to me, If some one makes me realize IMPORTANCE/REQUIREMENTS of "Design Patterns" or "MVC" or what ever.
PS: Pointer(links) or book suggestions are highly welcomed.
Re: is this a fancy way of writing PHP code??
Posted: Thu Jun 19, 2008 11:57 am
by claws
Just to make you more clear what is in my mind.
He used some thing like,
1. templates/*.tpl (which I never used in my life)
2. theme/*.theme (which I never used in my life)
3. completely seperated the HTML out of the functionality. (I'm not sure, may be this for changing the stylesheets/theme/template without touching the actual functionality of scripts)
4. look at the directory structure,
csv_bin
includes
changelog.txt
config.php
index.php
readme.en.txt
file.txt
csv_bin/dont_delete.txt
includes/css/
includes/html/
includes/php/
includes/css/default.css
includes/html/templates/
includes/html/themes/
includes/html/templates/data_select.tpl
includes/html/templates/error.tpl
includes/html/templates/index.tpl
includes/html/templates/locate.tpl
includes/html/templates/preview.tpl
includes/html/templates/preview_options.tpl
includes/html/templates/select_db_options.tpl
includes/html/templates/select_db_table.tpl
includes/html/templates/setup.tpl
includes/html/templates/setup_local.tpl
includes/html/templates/setup_remote.tpl
includes/html/templates/summary.tpl
includes/html/themes/default/
includes/html/themes/default/theme.tpl
includes/php/classes/
includes/php/functions.php
includes/php/lang/
includes/php/setup.php
includes/php/classes/_class.mysql.php
includes/php/classes/_class.output.php
includes/php/lang/en.php
looks highly organized and professional. If I had to write the same php importer, I would have wrote
1. css/*.css
2. images/
3. index.php (everything goes in this)
Does'n't my way look kiddish?
Re: is this a fancy way of writing PHP code??
Posted: Thu Jun 19, 2008 11:58 am
by Benjamin
I had a look at it and it seems to mostly be plain jane procedural code except for some class and template usage.
This like is scary though, due to the security implications:
Code: Select all
// Get all $_POST stuff and turn into vars
extract($_POST);
I wouldn't look to that as "professional" code.
Everyone is leaning towards pure OOP and MVC. So I would have a look at codeignitor or the Zend framework.
I wrote my own framework which works well for me, but I wouldn't call it professional.