473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

PHP "speed coding" tips

Hi everyone

I wondered what if any methods people here use to speed up their PHP
code (ie. speed at which you produce your code).

Things like 'code templates', 'base objects' for this and that?

I thought it would be interesting to find out if I'm missing out any
anything cool that could aid in speeding up development.

Thanks.
May 8 '07 #1
12 1847
On May 8, 12:42 pm, Tyno Gendo <you@localhostwrote:
Hi everyone

I wondered what if any methods people here use to speed up their PHP
code (ie. speed at which you produce your code).

Things like 'code templates', 'base objects' for this and that?

I thought it would be interesting to find out if I'm missing out any
anything cool that could aid in speeding up development.

Thanks.
Well, I don't think it's really something that matters. Like people
here say "Measure three times, cut only once", in programming it's the
same thing. It's better that you rethink your ideas in advance so you
don't have to write double code, to change your mind throw away last
two days and start solving the problem in different direction, to
organize the solution in such way that you can easily extend it later
etc.

The only "mechanic" thing you could do to make your coding faster
would be learning touch-typing, since watching at the keyboard
distracts you way too much from your code.

Cheers

May 8 '07 #2
Tyno Gendo wrote:
Hi everyone

I wondered what if any methods people here use to speed up their PHP
code (ie. speed at which you produce your code).

Things like 'code templates', 'base objects' for this and that?

I thought it would be interesting to find out if I'm missing out any
anything cool that could aid in speeding up development.

Thanks.
Hi,

speeding up the executiontime of code is of course a different matter than
speeding up your developmenttime.

Speed up execution: A lot can be said about this. I just want to say that
most scripts that that are slow use stupid/repetitive databasequeries.
Solution: Learn better SQL and fix it. :-)

Speed up developmenttime: This is a difficult matter and very personal to
most programmers I suspect.
My opinion: Whenever you start with a project that is modarate complex: be
sure you design your database in advance, before coding PHP.
A good databasedesign is the start. Understand concepts like normalization,
foreign keys, indexes, etc.
In the real world, you always must change your database during development.
The better your original design, the less pain.

As templates and third party objects go: I never use them, only PEAR
packages, and 'famous/proven' third party code like ADODB (not the VB
thing) and htmlmailers.

I have trouble folding my mind into other people's 'programming flowcharts'
or patterns, so I tend to write everything myself. That way I am sure I
know what I am doing.

If that is wise, I cannot say.
It saves time when you reuse other people's code.
It costs tremendously when the code fails and you can start debugging other
people's code.
In the end it is a matter of trust. Do I trust that X or Y wrote good code
that I dare to use in my software I develop?

I have (and many more coders too) a lib with functions I wrote and reuse in
different projects. I know how they work, and what they can or cannot do.
That saves time too.

If you are relatively new to PHP (I don't know your expertice), my advise
would be to first learn everything yourself, learn pitfalls, and write your
own code without templates/patterns/thirdparty addons/etc.
When you are comfortable with your skills, you can judge what packages you
trust enough to incorporate into your software.

It won't hurt to ask in here what people think about a certain framework or
package. If you receive a lot of complaints, don't use it of course! ;-)

Just my 2 cent.

Regards,
Erwin Moller

May 8 '07 #3
On May 8, 7:57 am, Erwin Moller
<since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
Tyno Gendo wrote:
Hi everyone
I wondered what if any methods people here use to speed up their PHP
code (ie. speed at which you produce your code).
Things like 'code templates', 'base objects' for this and that?
I thought it would be interesting to find out if I'm missing out any
anything cool that could aid in speeding up development.
Thanks.

Hi,

speeding up the executiontime of code is of course a different matter than
speeding up your developmenttime.

Speed up execution: A lot can be said about this. I just want to say that
most scripts that that are slow use stupid/repetitive databasequeries.
Solution: Learn better SQL and fix it. :-)

Speed up developmenttime: This is a difficult matter and very personal to
most programmers I suspect.
My opinion: Whenever you start with a project that is modarate complex: be
sure you design your database in advance, before coding PHP.
A good databasedesign is the start. Understand concepts like normalization,
foreign keys, indexes, etc.
In the real world, you always must change your database during development.
The better your original design, the less pain.

As templates and third party objects go: I never use them, only PEAR
packages, and 'famous/proven' third party code like ADODB (not the VB
thing) and htmlmailers.

I have trouble folding my mind into other people's 'programming flowcharts'
or patterns, so I tend to write everything myself. That way I am sure I
know what I am doing.

If that is wise, I cannot say.
It saves time when you reuse other people's code.
It costs tremendously when the code fails and you can start debugging other
people's code.
In the end it is a matter of trust. Do I trust that X or Y wrote good code
that I dare to use in my software I develop?

I have (and many more coders too) a lib with functions I wrote and reuse in
different projects. I know how they work, and what they can or cannot do.
That saves time too.

If you are relatively new to PHP (I don't know your expertice), my advise
would be to first learn everything yourself, learn pitfalls, and write your
own code without templates/patterns/thirdparty addons/etc.
When you are comfortable with your skills, you can judge what packages you
trust enough to incorporate into your software.

It won't hurt to ask in here what people think about a certain framework or
package. If you receive a lot of complaints, don't use it of course! ;-)

Just my 2 cent.

Regards,
Erwin Moller
Hi Erwin, I am a new PHP programmer too - I used to do plain HTML. My
answer might sound a bit pathetic, but it sure works: I rely on IDE,
but it must be a good one. I got NuSphere PhpED - they have what you
are asking for, code templates, code completion - + debugger, I think
this is one most important thing. I understand that this is different
from what you are talking about - I am not relying on any PHP
framework, but it sure serves me well, so I figure I'd share it with
out. Please forgive me if I am wasting your time :-)

May 8 '07 #4
On May 8, 3:42 am, Tyno Gendo <you@localhostwrote:
Hi everyone

I wondered what if any methods people here use to speed up their PHP
code (ie. speed at which you produce your code).

Things like 'code templates', 'base objects' for this and that?

I thought it would be interesting to find out if I'm missing out any
anything cool that could aid in speeding up development.

Thanks.
.... I can hear Leia now... "The faster you code, the more bugs will
slip through your fingers."

Some of the frameworks can add some speed once you get the hang of
them. Check out CakePHP (it's similar to Ruby on Rails):

http://www.cakephp.org/

A lot of speed is inherent in the design decisions you make, which
will come with experience.

Cheers,
Andrew

May 8 '07 #5
Tyno Gendo wrote:
Hi everyone

I wondered what if any methods people here use to speed up their PHP
code (ie. speed at which you produce your code).

Things like 'code templates', 'base objects' for this and that?

I thought it would be interesting to find out if I'm missing out any
anything cool that could aid in speeding up development.

Thanks.
Hi Gendo,

Better then producing more code per hour is to do more with less code:
the result is easier to change and it will probably contain less bugs
too. Since 1996 i have built 3 generations of frameworks to accomplish
this, nowadays i need very little code to build an application. Last
project i measured a productivity of between 200 and 900 times my
productivity back in 1996*. The framework is free to download and use,
but requires a good understanding of OOP, and even then it will take
some time before you get up to speed. It tends to replace coding with
exploring and thinking. Not everybody likes that.

Greetings,

Henk Verhoeven,
www.phpPeanuts.org.

* By then apps where GUI based, in Smalltalk, using a screen painter
tool and an Object to Relational DB Mapping library.
May 8 '07 #6
NC
On May 8, 3:42 am, Tyno Gendo <you@localhostwrote:
>
I wondered what if any methods people here use to speed
up their PHP code (ie. speed at which you produce your
code).

Things like 'code templates', 'base objects' for this and that?
It has gone way beyond that; these days, there are full-blown rapid
development frameworks... Unfortnately, applications you produce
using those tends to be slow.
I thought it would be interesting to find out if I'm missing
out any anything cool that could aid in speeding up
development.
Cool is a subjective notion.

Cheers,
NC

May 8 '07 #7

Tyno Gendo;63186 Wrote:
Hi everyone

I wondered what if any methods people here use to speed up their PHP
code (ie. speed at which you produce your code).

Things like 'code templates', 'base objects' for this and that?

I thought it would be interesting to find out if I'm missing out any
anything cool that could aid in speeding up development.

Thanks.
One of the ways I speed up my coding is by reusing generic code.
For example I have an email Class that have been using for a very long
time and on many sites.
So now I know that when my new code needs to send an email I don't need
to worry about that side of the work.

But I also think that all those little code bits only speed up _my_
development time as I am used to the functions and how to use them. Any
outsider would need to spend some time learning how to use it and
therefore loose a lot of the benefits I would gain.

FFMG
--

'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
(http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php)
'Free URL redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=14471

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

May 9 '07 #8
On May 8, 6:42 am, Tyno Gendo <you@localhostwrote:
Hi everyone

I wondered what if any methods people here use to speed up their PHP
code (ie. speed at which you produce your code).

Things like 'code templates', 'base objects' for this and that?

I thought it would be interesting to find out if I'm missing out any
anything cool that could aid in speeding up development.

Thanks.
First and foremost, a good IDE will save you gobs of time simply by
having autocompletion. (It'll also prevent accidental typos in
variable names).

You can get into code templates and whatnot, but sometimes I feel like
the time it takes to make the template ends up costing you more time
that it saves. I have a few code templates set up in Zend studio to
pop in some debug code that I delete once I find the problem, and that
is helpful, but I don't typically use code templates for production
code. My personal rule: if I have to rewrite the same logic 3 times,
then it's common enough that it belongs in a class or function, not in
a template.

May 9 '07 #9
Well when it comes to speeding up the development process people will
generally say that it's better to take your time and get it right the
first time.
This is true, but once you have succeeded in perfecting a peice of
code (such as connecting to a database) - you should save that code
and turn it into a snippet.

I use DreamWeaver 8, this program has built in snippet manager so if I
write a login system that I think should work for just about anyone, I
can save the code and depending on how you write it - you can simply
set variables at the top of the code.

For example, let's say I have a long login script with many options -
my options could be something like the following:

$userName = 1; // Ask for a username.
$userPass = 1; // Ask for a password.
$randImg = 0; // Don't generate random image verifcation.
$storeSession = 1; // Keep a session going for this login.
$storeCookie = 0; // Don't store a cookie for this login.
$rememberUser = 0; // Don't remember this user.
$formAction = "main.php"' // Where this form will be submitted.

This may be a little crude but this is the general concept. You have a
module that works - and all it needs are simple flags, and after this
is done you can generate an entire user management system in minutes.

I have written a script or two that I simply setup the INI file and
then run the script and it creates directories and files and sets up a
standard 5 page website with a content management system.

These are just some ideas.

On May 8, 3:42 am, Tyno Gendo <you@localhostwrote:
Hi everyone

I wondered what if any methods people here use to speed up their PHP
code (ie. speed at which you produce your code).

Things like 'code templates', 'base objects' for this and that?

I thought it would be interesting to find out if I'm missing out any
anything cool that could aid in speeding up development.

Thanks.

May 9 '07 #10
Moot wrote:
On May 8, 6:42 am, Tyno Gendo <you@localhostwrote:
>Hi everyone

I wondered what if any methods people here use to speed up their PHP
code (ie. speed at which you produce your code).

Things like 'code templates', 'base objects' for this and that?

I thought it would be interesting to find out if I'm missing out any
anything cool that could aid in speeding up development.

Thanks.

First and foremost, a good IDE will save you gobs of time simply by
having autocompletion. (It'll also prevent accidental typos in
variable names).

You can get into code templates and whatnot, but sometimes I feel like
the time it takes to make the template ends up costing you more time
that it saves. I have a few code templates set up in Zend studio to
pop in some debug code that I delete once I find the problem, and that
is helpful, but I don't typically use code templates for production
code. My personal rule: if I have to rewrite the same logic 3 times,
then it's common enough that it belongs in a class or function, not in
a template.
I HATE auto-completion! I'm a touch typist, and often am not looking at
my screen when I'm typing - especially code (i.e. referring to notes).
And it "help" just gets in my way :-).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 9 '07 #11
On May 8, 8:42 pm, Tyno Gendo <you@localhostwrote:
Hi everyone

I wondered what if any methods people here use to speed up their PHP
code (ie. speed at which you produce your code).

Things like 'code templates', 'base objects' for this and that?

I thought it would be interesting to find out if I'm missing out any
anything cool that could aid in speeding up development.

Thanks.
I found looking at how you work is very helpful. Looking at how you
design, how you turn it into code, where you need to improve, how you
can decrease debuging times by not injecting bugs etc. I landed on the
PSP process which requires that you log and analyse in detail how you
work. Its very involved process and its not for everyone, but I found
it useful as a guide.

There are other methodologies for this out there, but its really just
a case where you just sit back and keep an eye on how you work and
identify where you need improving then do so.



May 9 '07 #12
On May 8, 6:42 am, Tyno Gendo <you@localhostwrote:
Hi everyone

I wondered what if any methods people here use to speed up their PHP
code (ie. speed at which you produce your code).

Things like 'code templates', 'base objects' for this and that?

I thought it would be interesting to find out if I'm missing out any
anything cool that could aid in speeding up development.

Thanks.
Sometimes, using a (html) templating system (there are many,
http://smarty.php.net/ is the quintessence) can speed up your
development. Such things can also slow you down if used in the wrong
situation or in the wrong way. It might also keep you focused on the
PHP code when you are writing logic, and the browser code when you are
working on that. When I started using templating engines, I found that
I work more quickly. This can, in turn, increase page load time, but
alternatives to Smarty are often faster and worth the extra processing
requirements.

This is useless when writing a cron job, an AJAX serving script, a
reusable class, and a lot of other common things, but there are
probably more cases in which it can be used (not all when it /should/
be used).

-Mike PII

May 10 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Wm | last post by:
As an amateur wannabe-pro programmer, I am trying to learn not only how to use PHP but how to do it *efficiently*. (Trust me, you don't wanna see some of my stuff!!!) I'm noticing a number of my...
8
by: cainlevy | last post by:
I'm wondering if there's any way to speed up create table queries? Besides upgrading hardware, that is. The very simplest table creation query, "create table table1 ( field1 INT(10))" is taking...
0
by: Steve Holden | last post by:
EWT LLC and CCP h.f., having specific commercial interests in doing so, have decided to sponsor a sprint on the Python programming language with specific short- and medium-term acceleration goals....
1
by: patelxxx | last post by:
How to display PERL coding "Results" on webpages? What I'm trying to do is to display the result of the following PERL code on to a webpage and its not working. What can I do? ...
9
by: anon.asdf | last post by:
In terms of efficieny: Is it better to use multiple putchar()'s after one another as one gets to new char's OR is it better to collect the characters to a char-array first, and then use...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.