473,378 Members | 1,671 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,378 software developers and data experts.

General PHP applications

I want to know what is the ordinary style in creating PHP applications.
Should it be one main index.php which will be processing requests from
many htmls like in JSP technology?
Or what?
Thanks for any help and links.

And by the way please recomend me a free tool to write and debug PHP
applications (does not matter linux or windows).
I know only VS.Php for Visual Studio and this is what I am looking for -
syntax colors and running the application by one click.

Thanks!

--
Best regards,
Odwrotnie.
Mar 22 '06 #1
9 1472
> I want to know what is the ordinary style in creating PHP applications.
Should it be one main index.php which will be processing requests from
many htmls like in JSP technology?
Depends completly on the application. If it were a simple blog/homepage
I'd be tempted to just have one index page and a set of libraries to
include(). If it were a large-scale, multiuser site along the lines of
myspace or soemthing, I'd go for a modular approach that gives me
access to often-used functions throughout, but does not include
unneccesary code - e.g. calling 'modules' from the index page
(/index.php?mod=showUsers).

Its hard to explain the different approches you can take, but you
really need to look at the size of the application to begin with.
And by the way please recomend me a free tool to write and debug PHP
applications (does not matter linux or windows).


Use any text editor with syntax hilighting to write.
Testing can be done with a personal webserver, or install something
like PHPTriad on your machine (Apache, PHP, MySQL all in one package -
for windows). Theres another out there beggining with an X which has
perl and python too, but the name escapes me.

There are full blown PHP IDEs out there, but personally, I wouldn't
recommend any of them unless you need to collaborate your code with
other developers, and the only good ones seem to have a hefty price
tag.

Just my 2 cents anyway,

-- Matt

Mar 22 '06 #2
Check out Advanced PHP Programming by George Schlossnagle.

Personally I like to use an object oriented approach to keep pages
cleaner. Also, jedit is a good IDE. It provides PHP syntax
highlighting, code folding and has a large repository of user created
plugins. I like the FTP plugin for connecting to FTP and SFTP servers,
an (X)HTML plugin for auto-complete and tag matching, color wheel and
buffer tabs to display your open files in tabs.

Mar 22 '06 #3
odwrotnie wrote:
I want to know what is the ordinary style in creating PHP applications.
Should it be one main index.php which will be processing requests from
many htmls like in JSP technology?
Or what?
Thanks for any help and links.

And by the way please recomend me a free tool to write and debug PHP
applications (does not matter linux or windows).
I know only VS.Php for Visual Studio and this is what I am looking for
- syntax colors and running the application by one click.

(x)emacs has decent PHP support, I'm not sure if it's available for windows.

--
Ian Collins.
Mar 22 '06 #4
ge******@gmail.com wrote:

Use any text editor with syntax hilighting to write.
Testing can be done with a personal webserver, or install something
like PHPTriad on your machine (Apache, PHP, MySQL all in one package -
for windows). Theres another out there beggining with an X which has
perl and python too, but the name escapes me.

Don't forget that PHP scripts can be run form the command line, so you
don't require a webserver for testing.

--
Ian Collins.
Mar 22 '06 #5
odwrotnie wrote:
I want to know what is the ordinary style in creating PHP applications.
Should it be one main index.php which will be processing requests from
many htmls like in JSP technology?
Or what?
Thanks for any help and links.

And by the way please recomend me a free tool to write and debug PHP
applications (does not matter linux or windows).
I know only VS.Php for Visual Studio and this is what I am looking for -
syntax colors and running the application by one click.

Thanks!

--Best regards,
Odwrotnie.


Editor:
A reasonable freebie for editing in either environment is Eclipse
http://eclipse.org with the php plugin
http://www.phpeclipse.de/tiki-view_articles.php

Architecture:
It really depends on the demands that will be placed on the system.
Small applications can be routed through one central controller, more
complex systems may want to spread the load.

Personally, I like to have a 1:1 relationship between the code that
paints the screens (views) and the code that does the business logic
(controllers) and uses objects to talk to the database (model).

So, for example, if I have a subject 'foo', I will have a foo.php which
paints the screen and a foo.ctrl.php which has all the business logic.
This allows me to code things like foo.cell.php for cell phone displays,
etc. without changing the business logic code or the database access
code.

The rule is foo.php is only called by foo.ctrl.php (via a header()
redirect) and foo.php will only call foo.ctrl.php (via POST or GET).

-david-

Mar 22 '06 #6
I'm using php Coder, available form www.phpide.de

IT gives proper colours for all php coding. IT also contains a built in
browser, that can be linked to php and apache or IIS, to make it run.

IT is windows based.
odwrotnie wrote:
I want to know what is the ordinary style in creating PHP applications.
Should it be one main index.php which will be processing requests from
many htmls like in JSP technology?
Or what?
Thanks for any help and links.

And by the way please recomend me a free tool to write and debug PHP
applications (does not matter linux or windows).
I know only VS.Php for Visual Studio and this is what I am looking for -
syntax colors and running the application by one click.

Thanks!

--
Best regards,
Odwrotnie.


Mar 23 '06 #7
THANKS!!! YOU HAVE HELPED ME A LOT!

--
Best regards,
Odwrotnie.
Mar 23 '06 #8
On Wed, 22 Mar 2006 23:02:36 +0100, David Haynes
<da***********@sympatico.ca> wrote:
The rule is foo.php is only called by foo.ctrl.php (via a header()
redirect) and foo.php will only call foo.ctrl.php (via POST or GET).


Can You give me examples about "via a header()" and "redirect" and POST
and GET. I dont really understand what do You mean (I am new to php)...

--
Best regards,
Odwrotnie.
Mar 23 '06 #9
odwrotnie wrote:
On Wed, 22 Mar 2006 23:02:36 +0100, David Haynes
<da***********@sympatico.ca> wrote:
The rule is foo.php is only called by foo.ctrl.php (via a header()
redirect) and foo.php will only call foo.ctrl.php (via POST or GET).


Can You give me examples about "via a header()" and "redirect" and POST
and GET. I dont really understand what do You mean (I am new to php)...

--Best regards,
Odwrotnie.

Sure.

POST and GET refer to the way data may be passed from an HTML <form> to
a program - in this case a php program. So, when you create a form, you
have something like:

<form action="foo.ctrl.php" method="POST">
<input type="text" name="something">
<input type="submit">
</form>

Clicking on the OK button (of the submit) will cause the data in the
'text' variable to be sent to the program foo.ctrl.php.

The foo.ctrl.php program can access the 'something' data as
$_POST['something'].

If you set method="GET" or use a url like
http://foo.ctrl.php?something="hey there", then the program can access
the 'something' data as $_GET['something'].

Let's say that foo.ctrl.php wants to display the value of 'something' in
a web page. My way would be to have foo.ctrl.php redirect the http
session to the display page using a header() call.

For example:

<?php
header("Location: show_text.php?something=$_POST['something']");
?>

The page show_text.php can get the text data using the $_GET['something'].
For example:

<html>
....
<body>
The text you entered is <?php echo $_GET['something'];?><br/>
</body>
</html>

Now, sending a lot of data to a form via the URL string can get very
messy. PHP provides another method - sessions - to pass data quietly.

Using sessions, php.ctrl.php would become:

<?php
session_start();
$_SESSION['something'] = $_POST['something'];
session_write_close();
header("Location: show_text.php");
?>

and show_text.php would become:
<?php
start_session();
?>
<html>
....
<body>
The text you entered is <?php echo $_SESSION['something'];?><br/>
</body>
</html>

The location command has its own issues. Someone posted a nice routine
(I'm sorry but I can't recall who it was) to enhance the location
command. My version of this is:

/**
* Module: redirect.inc
*
* Manages a redirection when there may be a session active.
* Also correctly re-addresses URLs that are not absolute.
*
* @param string $url
*/
function redirect($url) {
if( substr($url, 0, 4) != 'http' ) {
if( isset($_SERVER['HTTP_HOST']) ) {
$url = 'http://'.$_SERVER['HTTP_HOST'].$url;
} else {
$url = 'http://localhost'.$url;
}
}
session_write_close();
header("location: $url");
exit;
}

This function makes all url addresses absolute and ensures that the
session is committed prior to the header() redirect.
(Thanks again to the original poster)

This should get you started.

-david-

Mar 23 '06 #10

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

Similar topics

3
by: relaxedrob | last post by:
Howdy All! I must admit that the more I use and learn JavaScript, the more convinced I am that it is one of the most expressive languages I know. Without ways to access file i/o or databases...
0
by: Demetri | last post by:
Hi Forgive me if this is not the correct place to post this type of question. Its the only place I could find that is general enough I'm a developer for a good sized company. We have MANY...
1
by: Andrew MacLean | last post by:
Hello all, I am fairly new to .NET, but not to VB. I have a couple of questions. 1. Shared Code Base I have a solution with several different applications within it. Many of the...
4
by: marcel | last post by:
Hi, I have written a component in c#. But when I recompile this component, all other apps which includes my component can not start correctly: An exception "System.IO.FileLoadExceptio" occurred....
6
by: Alex | last post by:
Hello I am intersting in developing and my background is VBA used in Excel and a brief intro to Java. I am interested in learning beyond VB and feel that C++ would be a very good language to...
6
by: David | last post by:
I am running into situtations where confining all forms to just one window (instance of broswer) is becoming overly restrictive. Does ASP.NET provide ways to have multiple windows to interact with...
2
by: adrian.chandler | last post by:
Hi all, I have been using letter and symbol codes such as GNU< GNU\ GNU} GNUˆ in an Access table. I was surprised to see that when the table was sorted on this field, the order is: GNUˆ...
0
by: Michael.Suarez | last post by:
So we develop and maintain several applications used by several people in the same company, on the same intranet. There are several applications written in VB6, but going forward all of the new...
2
by: Doug | last post by:
Hi, I wanted to start a general discussion more for getting some thoughts on what other people think/practice out there just to see how far (if at all) I'm off base on my own thoughts. My...
3
by: Mike TI | last post by:
Aug 2, 2007 12:00pm Hi all I have to design and program an application which will be used in three countries. It would be a fairly large application with lot of data entry. The database...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.