|
P: n/a
|
grz02
Hi,
Im an experienced database+software designer and developer,
but, unfortunately, anything to do with web-programming and
web-systems designs is still a pretty new area to me...
(been working mostly with "legacy" environments the last 10 years)
So I am writing this, hoping to get some useful advise and feedback...
I have done some pretty trivial, small websites with html/PHP,
and now starting a bit more advanced one, where I will need SQL
database-support, and will probably go for MySQL.
Of course, I have read some elemantary tutorials and articles on the web,
but still wonder how PHP is actually being used in practice when
creating bigger web-sites...
Is PHP usually handcoded?
Like... you just make up a database, then a number of tables you think will do,
and finally (what I am most concerned about) a multiplicity of different
PHP script-files in an ad-hoc fashion?
(I hope not, since it seems that this will quite soon produce a pretty
diffcult-to-maintain-and-grasp mess of the whole system)
So what I would like to learn, is what nice (preferrably free/open-source)
tools for design and project-management are available?
My idea is that you would like to have some IDE application, something
like VB or Delphi or VC++, where you design your webpages and
forms in a graphical manner, and you can code "event" pieces of code
that will react to clicks, buttons and user-actions like
in the traditional IDE:s.
And then there is some "compiler" or rather that do all the boring routine-work
of converting your design to html/PHP code.
The page-designs would also be based on "templates", of course,
so its flexible to modify if you want to change the look-and-feel
of your whole site.
Ideally, I would also prefer that the whole website-design
would be stored in a separate, fixed set of tables in the database,
rather than in a zillion different script-files, CSS-sheets, etc.
I can also envision a design where, even if the website contains
a huge number of pages and different functions,
there would actually only be a single PHP-script "index.php"
and all sub-pages are generated on-the-fly, from arguments
in the URL, i.e. all URLs simply looking like:
index.php?pageid=1
index.php?pageid=2
...
index.php?pageid=productlist
index.php?pageid=registration
index.php?pageid=loginform
index.php?pageid=contactform
etc...
The index.php startfile might only look something like:
<html>
<php?
include("lib.php");
main();
?>
</html>
Then all pages would be generated on-the-fly by the main() function
(defined in "lib.php", along with a host of useful subroutines),
and driven by the URL-parameter 'pageid' and the overall site-design
somehow stored in the database.
All design-work you did in the IDE (graphical, code-snippets, etc)
would then actually be stored in the DB, and the PHP script-files
could then be a quite static PHP-implementation of an "engine"
reading the DB-content and outputting the HTML-code and pages.
So... could you please give me a short brief/hints/links to what
IDEs and/or other free tools, along those lines, that already exist
or what are commonly used for PHP/MySQL in real-world development.
Thanks, | |
Share this Question
|
P: n/a
|
Juha Suni
grz02 wrote:[color=blue]
> So... could you please give me a short brief/hints/links to what
> IDEs and/or other free tools, along those lines, that already exist
> or what are commonly used for PHP/MySQL in real-world development.[/color]
Hi!
Im not an expert on the matter since I've done most of my routines,
classes and template engines myself, but just some sites you might want
to check out come to mind.
See the popular Smarty template engine at: http://smarty.php.net/
And for a real PHP IDE at least check out Zends PHP Studio at http://www.zend.com/store/products/zend-studio.php?home
For mySQL database management there is of course at least PhpMyAdmin: http://www.phpmyadmin.net
I know there are tons of others but without real personal experience on
those, I will let others inform you.
HTH
--
Suni | | |
P: n/a
|
Tony Marston
"grz02" <grz01@spray.se> wrote in message
news:1641ee43.0410071356.717fb49e@posting.google.c om...[color=blue]
> Hi,
>
> Im an experienced database+software designer and developer,
> but, unfortunately, anything to do with web-programming and
> web-systems designs is still a pretty new area to me...
> (been working mostly with "legacy" environments the last 10 years)
>
> So I am writing this, hoping to get some useful advise and feedback...
>
> I have done some pretty trivial, small websites with html/PHP,
> and now starting a bit more advanced one, where I will need SQL
> database-support, and will probably go for MySQL.
>
> Of course, I have read some elemantary tutorials and articles on the web,
> but still wonder how PHP is actually being used in practice when
> creating bigger web-sites...
>
> Is PHP usually handcoded?
> Like... you just make up a database, then a number of tables you think
> will do,
> and finally (what I am most concerned about) a multiplicity of different
> PHP script-files in an ad-hoc fashion?
> (I hope not, since it seems that this will quite soon produce a pretty
> diffcult-to-maintain-and-grasp mess of the whole system)[/color]
The way to Rapid Application Development (RAD) in any language, not just
PHP, is to have a solid architectural framework with lots of reusable
modules which you can access in order to build individual components or
transactions. You may start by using something pre-written by somebody else,
but once you have sussed out how it works you may wish to customise it,
either because you wish to add more options, or because your personal style
is different.
When it comes to architectural frameworks I would suggest the 3-tier
architecture or Model-View-Controller (personally I use both combined). The
3-tier architecture includes a Data Access Object (DAO) which contains the
code which carries out all communication with the database.
When it comes to building individual components with their own screens you
can either produce all HTML tags from within your PHP code, or you can use a
templating system. Personally I use XSL transformations from XML data as it
is controlled by W3C standards and is used widely across the entire
industry, not just within the PHP world.
If you want further ideas you can browse the articles on my website at http://www.tonymarston.co.uk/php-mysql/index.html
[color=blue]
> So what I would like to learn, is what nice (preferrably free/open-source)
> tools for design and project-management are available?
>
> My idea is that you would like to have some IDE application, something
> like VB or Delphi or VC++, where you design your webpages and
> forms in a graphical manner, and you can code "event" pieces of code
> that will react to clicks, buttons and user-actions like
> in the traditional IDE:s.[/color]
Web pages do not have "events" like traditional desktop applications. The
client issues an HTTP request, the web server recives it and generates a
response. Web pages are also stateless, which involves another big change in
thinking.
[color=blue]
> And then there is some "compiler" or rather that do all the boring
> routine-work
> of converting your design to html/PHP code.[/color]
PHP code is not compiled, it is interpretted. However, there are third-party
utilities that are able to cache the intermedaite bytecode.
[color=blue]
> The page-designs would also be based on "templates", of course,
> so its flexible to modify if you want to change the look-and-feel
> of your whole site.[/color]
Templating systems do not come built into PHP, you have you choose one and
plug it in to your framework.
[color=blue]
> Ideally, I would also prefer that the whole website-design
> would be stored in a separate, fixed set of tables in the database,
> rather than in a zillion different script-files, CSS-sheets, etc.[/color]
Dream on. Unless you can configure your web server to access a database you
MUST have scripts as files in a directory.
[color=blue]
> I can also envision a design where, even if the website contains
> a huge number of pages and different functions,
> there would actually only be a single PHP-script "index.php"
> and all sub-pages are generated on-the-fly, from arguments
> in the URL, i.e. all URLs simply looking like:[/color]
Yuck! You are talking about a front controller. Personally I would avoid
such things like the plague and go for smaller page controllers.
[color=blue]
> index.php?pageid=1
> index.php?pageid=2
> ...
> index.php?pageid=productlist
> index.php?pageid=registration
> index.php?pageid=loginform
> index.php?pageid=contactform
>
> etc...
>
> The index.php startfile might only look something like:
>
> <html>
> <php?
> include("lib.php");
> main();
> ?>
> </html>
>
> Then all pages would be generated on-the-fly by the main() function
> (defined in "lib.php", along with a host of useful subroutines),
> and driven by the URL-parameter 'pageid' and the overall site-design
> somehow stored in the database.
>
> All design-work you did in the IDE (graphical, code-snippets, etc)
> would then actually be stored in the DB, and the PHP script-files
> could then be a quite static PHP-implementation of an "engine"
> reading the DB-content and outputting the HTML-code and pages.[/color]
WYSIWYG editors for web pages are notorious for producing inefficient HTML
code. Quite frankly if you are unable to build web pages without such an
editor then your are a pretty poor developer. PHP was designed to produce
HTML tags, so if you do not know how to generate HTML tags manually you will
find PHP too difficult for your limited abilities.
[color=blue]
> So... could you please give me a short brief/hints/links to what
> IDEs and/or other free tools, along those lines, that already exist
> or what are commonly used for PHP/MySQL in real-world development.[/color]
Different developers use different combinations of tools to achieve their
purpose. I do it one way, but a thousand other developers will do it a
thousand other ways. Who is right? We all are. You pays your money and you
takes your choice.
Happy hunting.
--
Tony Marston http://www.tonymarston.net | | |
P: n/a
|
Tim Tyler
grz02 <grz01@spray.se> wrote or quoted:
[color=blue]
> I can also envision a design where, even if the website contains
> a huge number of pages and different functions,
> there would actually only be a single PHP-script "index.php"
> and all sub-pages are generated on-the-fly, from arguments
> in the URL, i.e. all URLs simply looking like:
>
> index.php?pageid=1
> index.php?pageid=2
> ...
> index.php?pageid=productlist
> index.php?pageid=registration
> index.php?pageid=loginform
> index.php?pageid=contactform
>
> etc...
>
> The index.php startfile might only look something like:
>
> <html>
> <php?
> include("lib.php");
> main();
> ?>
> </html>[/color]
That's called a "front controller". http://www.phppatterns.com/index.php...leview/81/1/1/
....is an article about front controllers in PHP.
It is good - but AFAICS, the arguments given against front controllers
in it are hogwash.
The main objections are:
``In the simple example above, that may not seem like a problem, but what
about when you have hundreds of Page Controllers? You end up with a
massive switch statment or perhaps something disguised in an array, an
XML document or whatever. For every page request, PHP will have to
reload a bunch of data which is irrelevant to the current request the
user is trying to perform.''
This is fundamentally the same task a webserver performs when looking up a
file in a filing system. If PHP is doing the task, the webserver
doesn't have to. It might be a bit slower in PHP than in C - but
that's hardly a reason for not doing it in PHP.
....and...
``The other problem with running everything through a single PHP script,
such as index.php, is it imposes a significant restriction on the
flexibility PHP offers, by default, of allowing developers to "drop a
script" anywhere under the web server's web root directory. Adopting
this approach will likely cause you problems later, both from the
practical perspective of having to updating the command hierarchy each
time you create a new file to issues like integration with other PHP
applications.''
....which seems like nonsense to me. If you /must/ access code that
is incompatible with a front controller (for some reason) nothing
stops you from doing so. You lose the front controller's facilities
in the process - but the alternative is not having them at all in
the first place - so in practice little is lost.
Storing your code in a filing system is a bit backwards - since
you have to do independent version control, history tracking,
backups, permission handling and updates.
Everything should go into a database.
Microsoft realised this - with WinFS: http://msdn.microsoft.com/Longhorn/u...S/default.aspx
....but have yet to pull it off.
--
__________
|im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply. | | |
P: n/a
|
Tim Van Wassenhove
In article <I59pBA.1pM@bath.ac.uk>, Tim Tyler wrote:[color=blue]
> It is good - but AFAICS, the arguments given against front controllers
> in it are hogwash.
>
> The main objections are:
>
> ``In the simple example above, that may not seem like a problem, but what
> about when you have hundreds of Page Controllers? You end up with a
> massive switch statment or perhaps something disguised in an array, an
> XML document or whatever. For every page request, PHP will have to
> reload a bunch of data which is irrelevant to the current request the
> user is trying to perform.''
>
> This is fundamentally the same task a webserver performs when looking up a
> file in a filing system. If PHP is doing the task, the webserver
> doesn't have to. It might be a bit slower in PHP than in C - but
> that's hardly a reason for not doing it in PHP.[/color]
The fileserver has to do a lookup anyways, to map the request to the
controller script. Thus you end up with 2 lookups, where the first is
pure overhead. In the case you want to have some code that is executed
in every script you can also consider using the auto_prepend and
auto_append functionality php has.
My conclusion: The added value of a controller is 0. Not even
mentionning that the chances for introducing bugs in your request->page
mapper. Where the code in your webserver has been tested many times
before.
[color=blue]
> Storing your code in a filing system is a bit backwards - since
> you have to do independent version control, history tracking,
> backups, permission handling and updates.
>
> Everything should go into a database.[/color]
Imho, a file system is a database.
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info> | | |
P: n/a
|
Christian Fersch
grz02 wrote:[color=blue]
> Im an experienced database+software designer and developer,
> but, unfortunately, anything to do with web-programming and
> web-systems designs is still a pretty new area to me...
> (been working mostly with "legacy" environments the last 10 years)[/color]
First thing to remember: This html + http. Your possibilities are very
limited (and also the work for you to do ;). But this also makes
UI-Design the most important thing when writing php-code, for the code
itself is not really a problem. But UI-Design is very difficult, for you
can barely interact with the user.
IMHO this makes php very different from any other programming language.
[color=blue]
> Is PHP usually handcoded?[/color]
Yeah, I would say so - but that doesn't mean that you will have to do it.
[color=blue]
> Like... you just make up a database, then a number of tables you think will do,
> and finally (what I am most concerned about) a multiplicity of different
> PHP script-files in an ad-hoc fashion?
> (I hope not, since it seems that this will quite soon produce a pretty
> diffcult-to-maintain-and-grasp mess of the whole system)[/color]
This is done quite often with php (the wbb is written this way), but
this definitely doesn't mean, that it is a good way.
[color=blue]
> So what I would like to learn, is what nice (preferrably free/open-source)
> tools for design and project-management are available?[/color]
For php: Not really any.
[color=blue]
> My idea is that you would like to have some IDE application, something
> like VB or Delphi or VC++, where you design your webpages and
> forms in a graphical manner, and you can code "event" pieces of code
> that will react to clicks, buttons and user-actions like
> in the traditional IDE:s.
> And then there is some "compiler" or rather that do all the boring routine-work
> of converting your design to html/PHP code.
> The page-designs would also be based on "templates", of course,
> so its flexible to modify if you want to change the look-and-feel
> of your whole site.[/color]
Of course you should use templates for any of your projects (I would say
that everything with more than 30 lines of codes should use a
template-system). Which template engine to use is your first decision
(smarty, etc or a self-written?).
But the thing with vb-like design and events is neither available nor
needed - html does this already. There are no events, all fields are
perfectly given to you in the $_REQUEST variable - nothing more to want.
What you seem to be looking for is a WYSIWYG Editor for html. Of course
you can use one (I'd say dreamweaver is definitely the best one for
windows, but it's not free), but that has nothing to do with php, but
rather just a matter of your html-design. You could also write you html
in a text-editor - it's not such a big difference, once you've learned it.
[color=blue]
> Ideally, I would also prefer that the whole website-design
> would be stored in a separate, fixed set of tables in the database,
> rather than in a zillion different script-files, CSS-sheets, etc.[/color]
CSS should stay in files, for there is no use in storing it in tables.
One big css file for your whole site will do it. If you don't like
files, you can of course store your templates in the database, but this
is not making a real difference. You will change a zillion different
files to a zillion different table-rows...
[color=blue]
> I can also envision a design where, even if the website contains
> a huge number of pages and different functions,
> there would actually only be a single PHP-script "index.php"
> and all sub-pages are generated on-the-fly, from arguments
> in the URL, i.e. all URLs simply looking like:
>
> index.php?pageid=productlist
>
> etc...[/color]
[snip][color=blue]
> Then all pages would be generated on-the-fly by the main() function
> (defined in "lib.php", along with a host of useful subroutines),
> and driven by the URL-parameter 'pageid' and the overall site-design
> somehow stored in the database.[/color]
This isn't such a good thing to do. You should combine some functions in
one file, but not all - this will get big and bloated and your urls will
look ugly and will be hard to understand. Just look at some forums (not
the wbb - it's coding style is complete shit) - they have 5-15 files,
each dedicated to a set of functions (one for thread-handling, one for
post-handling, one for the user-profile and settings, and the admin
control panel completely separated into a separate dir). I'd say that
this is the right way to do it.
[color=blue]
> All design-work you did in the IDE (graphical, code-snippets, etc)
> would then actually be stored in the DB, and the PHP script-files
> could then be a quite static PHP-implementation of an "engine"
> reading the DB-content and outputting the HTML-code and pages.[/color]
That's what templates do.
[color=blue]
> So... could you please give me a short brief/hints/links to what
> IDEs and/or other free tools, along those lines, that already exist
> or what are commonly used for PHP/MySQL in real-world development.[/color]
The best editor for windows is NuSphere's phpEd. But it costs 500$. Good
- completely free - tools are rare for php (on windows).
I'd say you have a strange view of php and should think about a bit, for
most of what you wanted an IDE to do is done with a template-system and
the already existing separation of processing-code ->PHP and design and
interface code ->HTML.
greetings, Christian | | |
P: n/a
|
Tony Marston
"Tim Tyler" <tim@tt1lock.org> wrote in message news:I59pBA.1pM@bath.ac.uk...[color=blue]
> grz02 <grz01@spray.se> wrote or quoted:
>[color=green]
>> I can also envision a design where, even if the website contains
>> a huge number of pages and different functions,
>> there would actually only be a single PHP-script "index.php"
>> and all sub-pages are generated on-the-fly, from arguments
>> in the URL, i.e. all URLs simply looking like:
>>
>> index.php?pageid=1
>> index.php?pageid=2
>> ...
>> index.php?pageid=productlist
>> index.php?pageid=registration
>> index.php?pageid=loginform
>> index.php?pageid=contactform
>>
>> etc...
>>
>> The index.php startfile might only look something like:
>>
>> <html>
>> <php?
>> include("lib.php");
>> main();
>> ?>
>> </html>[/color]
>
> That's called a "front controller".
>
> http://www.phppatterns.com/index.php...leview/81/1/1/
>
> ...is an article about front controllers in PHP.
>
> It is good - but AFAICS, the arguments given against front controllers
> in it are hogwash.[/color]
No they're not. IMHO they are perfectly sound. Front controllers were
designed for languages such as Java which have web servers which behave
differently to Apache. With Apache you can have a URL that says www.site.com/page256.php?arg1=foo&arg2=bar and it will go straight to the
requseted page. Using http://www.site.com/index.php?page=2...1=foo&arg2=bar
means that everything has to go through index.php first, and index.php must
then contain code to redirect to page256.php. Not only is this an unecessary
overhead, it also means that every time you change your application you must
remember to update index.php. This is a disaster waiting to happen, IMHO. I
much prefer having a separate controller for each page.
--
Tony Marston http://www.tonymarston.net
[color=blue]
> The main objections are:
>
> ``In the simple example above, that may not seem like a problem, but what
> about when you have hundreds of Page Controllers? You end up with a
> massive switch statment or perhaps something disguised in an array, an
> XML document or whatever. For every page request, PHP will have to
> reload a bunch of data which is irrelevant to the current request the
> user is trying to perform.''
>
> This is fundamentally the same task a webserver performs when looking up a
> file in a filing system. If PHP is doing the task, the webserver
> doesn't have to. It might be a bit slower in PHP than in C - but
> that's hardly a reason for not doing it in PHP.[/color]
The web server does not have a massive switch statement. It simply has the
name of one of thousands of possible files that may exist on your file
system.
[color=blue]
> ...and...
>
> ``The other problem with running everything through a single PHP script,
> such as index.php, is it imposes a significant restriction on the
> flexibility PHP offers, by default, of allowing developers to "drop a
> script" anywhere under the web server's web root directory. Adopting
> this approach will likely cause you problems later, both from the
> practical perspective of having to updating the command hierarchy each
> time you create a new file to issues like integration with other PHP
> applications.''
>
> ...which seems like nonsense to me. If you /must/ access code that
> is incompatible with a front controller (for some reason) nothing
> stops you from doing so. You lose the front controller's facilities
> in the process - but the alternative is not having them at all in
> the first place - so in practice little is lost.[/color]
You do not lose any functionality of a front controller by using separate
page controllers. There is nothing that can be done in a front controller
that cannot be done in separate page controllers.
[color=blue]
> Storing your code in a filing system is a bit backwards - since
> you have to do independent version control, history tracking,
> backups, permission handling and updates.
>
> Everything should go into a database.[/color]
Who says?
[color=blue]
> Microsoft realised this - with WinFS:
>
> http://msdn.microsoft.com/Longhorn/u...S/default.aspx
>
> ...but have yet to pull it off.[/color]
Just because Microsoft say something does not mean that it is a good idea.
--
Tony Marston http://www.tonymarston.net | | |
P: n/a
|
Henk Verhoeven
Hi grz,
This is a lot of questions/ideas/requirements. We have developed an open
source framework for development of web based applications. It is called
phpPeanuts. It seems to be close to some of your ideas but quite far
from others. This has to do with design choices we made. I will begin
with the similarities, then go into the differences.
[color=blue]
> I can also envision a design where, even if the website contains
> a huge number of pages and different functions,
> there would actually only be a single PHP-script "index.php"
> and all sub-pages are generated on-the-fly, from arguments
> in the URL, i.e. all URLs simply looking like:
>
> index.php?pageid=1
> index.php?pageid=2
> ...
> index.php?pageid=productlist
> index.php?pageid=registration[/color]
Something like that yes:
index.php?pntType=Product&pntHandler=EditDetailsPa ge&id=1
The index.php script will give you a form for editing the Product with
id = 1. Or more precise, it will probably include the file that contains
the class ObjectEditDetailsPage, instantiate it and forward it the
request*. ObectEditDetailsPage will use its inherited function
getRequestedObject() to obtain an instance of the class Product with id
= 1, and generate and output a form for displaying and editing its
properties. The form may be generated entirely from metadata. No need to
have a database with forms. No boring designing forms for Product,
Customer, Order, Shipment and all those other types you need. Just one
single generic site design. Then if you specify the metadata in the
Product class, the rest done is automaticly.
As you see our aproach is object oriented. This means that we do not
have a big pile of functions in which an engine is implemented, that
processes passive data from a database. We rather have an assembly of
objects that cooperate to do the work. Objects combine functions and
data. This makes them much more flexible then just trying to represent
the entire website desing in data (like your design seems to do) or in
functions (like standard php scripting tends to do).
With object orientation it is possible to offer the developer a default
user interface for his application, and at the same time to allow the
developer to specialize allmost any aspect of both the engine and the
design by creating subclasses and overriding some methods. Because the
methods are written in php, he can put in any code he likes, so he is
not limited to what the existing engine can do.
Like with most traditional IDE's, the user interface is composed from
objects, like listboxes, tables, buttons, dialogs, etc. Only the
phpPeanuts objects do not exist in the client PC and draw on the screen,
but rather exist on the server, process requests and output HTML. For
lists of user interfacing classes by category see http://www.phppeanuts.org/site/index...t.web/web.html
Of course there is still a need for a place to put pieces of HTML that
hold parts of the design. We could have stored them in the database, or
use a template enigine, but we chose 'the simpelest thing that could
possibly work': php include files. These have the advantage that you can
include pieces of php to call methods. See http://www.phppeanuts.org/site/index...principle.html
for how all this fits together.
But if you like it better to have a database, be my guest: make some
subclasses, override the methods that currently do the inclusion and
fetch and interpret your design data from there... (actually you may hit
a design limitation here, or maybe it has already been solved. Anyhow,
if you explain how our design limits you you to specilize the framework
in the way you need to, we will be happy see if we can make the
necessary adaptations)
[color=blue]
> and you can code "event" pieces of code
> that will react to clicks, buttons and user-actions like
> in the traditional IDE:s.[/color]
We do in specific situations support event handler methods. However,
http works with url's, requests and pages that are returned. So our user
interfacing framework focusses on handling requests and composing pages
and forms. Only where the composition needs to be specialized in
repeated details you will need to implement event handler methods.
Otherwise it is a matter of specializing classes that becuase they exist
override the defaults and override methods.
We do not support IDE style WYSIWYG graphically editing a user
interface. In an earlier version of the framework (in Java) we had an
template technique for this, but even with dreamweaver it proved to be a
lot of work to manually desing the user interface of a substantial
application. The problem was a lack of abstraction. The result wass lots
of replication, little reuse. We tried to make our objects editable with
dreamweaver, but that was too cumbersome. Existing WYSIWYG editors
simply could not cope with the dynamics of objects. (For some reason
none of them supported the JavaBeans standard the way IDE's do).
It would still be nice to have a way to WYSIWIG edit the bits and pieces
of html the design is composed from. Preferably i would have that in the
browser, as part of the working application. But building that is a huge
effort, and the more we can reuse pieces of design, the less we can
gain from it. But if anyone has substantial leftover money i would be
happy to look into it ;-)
I guess this is the basic difference between traditional IDE's and
phpPeanuts: IDE's try to facilitate graphical designing and coding. We
build components and try to faciltate their reuse. The more you can
reuse, the less design and code you need for the same end user function.
We believe that in the long run this gives a higer productivity then
traditional IDE's and results in more flexible applications, in the
sense of easyer to adapt to new or changing requirements.
Greetings,
Henk Verhoeven, www.phpPeanuts.org.
* The mapping of urls to objects is called Request Dispatch and it is
acutally a bit more complicated, see http://www.phppeanuts.org/site/index...+dispatch.html | | |
P: n/a
|
Tim Tyler
Tim Van Wassenhove <euki@pi.be> wrote or quoted:[color=blue]
> In article <I59pBA.1pM@bath.ac.uk>, Tim Tyler wrote:[/color]
[color=blue][color=green]
> > It is good - but AFAICS, the arguments given against front controllers
> > in it are hogwash.
> >
> > The main objections are:
> >
> > ``In the simple example above, that may not seem like a problem, but what
> > about when you have hundreds of Page Controllers? You end up with a
> > massive switch statment or perhaps something disguised in an array, an
> > XML document or whatever. For every page request, PHP will have to
> > reload a bunch of data which is irrelevant to the current request the
> > user is trying to perform.''
> >
> > This is fundamentally the same task a webserver performs when looking up a
> > file in a filing system. If PHP is doing the task, the webserver
> > doesn't have to. It might be a bit slower in PHP than in C - but
> > that's hardly a reason for not doing it in PHP.[/color]
>
> The fileserver has to do a lookup anyways, to map the request to the
> controller script.[/color]
Examine the work it has to do - depending on the structure of the
filing system. The fewer files, the less work.
[color=blue]
> In the case you want to have some code that is executed
> in every script you can also consider using the auto_prepend and
> auto_append functionality php has.[/color]
Doesn't using auto_prepend require php.ini/httpd.conf access - and affect
*everything*?
It doesn't make much difference - the main issue here - IMO - is whether
the site is in the filing system or the database.
[color=blue]
> My conclusion: The added value of a controller is 0. Not even
> mentionning that the chances for introducing bugs in your request->page
> mapper. Where the code in your webserver has been tested many times
> before.[/color]
Why can't a front controller be "tested many times before"?
Code can be shared. Not everyone has to reinvent the wheel.
[color=blue][color=green]
> > Everything should go into a database.[/color]
>
> Imho, a file system is a database.[/color]
It is.
It is a crappy one, with poor versioning, searching, filtering and sorting
facilities.
--
__________
|im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply. | | |
P: n/a
|
Tim Tyler
Tony Marston <tony@nospam.demon.co.uk> wrote or quoted:[color=blue]
> "Tim Tyler" <tim@tt1lock.org> wrote in message news:I59pBA.1pM@bath.ac.uk...[color=green]
> > grz02 <grz01@spray.se> wrote or quoted:[/color][/color]
[color=blue][color=green][color=darkred]
> >> I can also envision a design where, even if the website contains
> >> a huge number of pages and different functions,
> >> there would actually only be a single PHP-script "index.php"
> >> and all sub-pages are generated on-the-fly, from arguments
> >> in the URL, i.e. all URLs simply looking like:
> >>
> >> index.php?pageid=1
> >> index.php?pageid=2
> >> ...
> >> index.php?pageid=productlist
> >> index.php?pageid=registration
> >> index.php?pageid=loginform
> >> index.php?pageid=contactform
> >>
> >> etc...
> >>
> >> The index.php startfile might only look something like:
> >>
> >> <html>
> >> <php?
> >> include("lib.php");
> >> main();
> >> ?>
> >> </html>[/color]
> >
> > That's called a "front controller".
> >
> > http://www.phppatterns.com/index.php...leview/81/1/1/
> >
> > ...is an article about front controllers in PHP.
> >
> > It is good - but AFAICS, the arguments given against front controllers
> > in it are hogwash.[/color]
>
> No they're not. IMHO they are perfectly sound. Front controllers were
> designed for languages such as Java which have web servers which behave
> differently to Apache. With Apache you can have a URL that says
> www.site.com/page256.php?arg1=foo&arg2=bar and it will go straight to the
> requseted page. Using http://www.site.com/index.php?page=2...1=foo&arg2=bar
> means that everything has to go through index.php first, and index.php must
> then contain code to redirect to page256.php.[/color]
You are complaining about the performance cost of reading a file like:
<php?
include("lib.php");
main();
?>
....from the server?
For those anal about performance, that seems to be more than compensated
for by the lack of a need to include:
include("header.php");
....
include("footer.php");
....in every single page - and besides, that file should get cached and
ought to take practically no time to read.
[color=blue]
> Not only is this an unecessary overhead, it also means that every time
> you change your application you must remember to update index.php.[/color]
When index.php looks like:
<php?
include("lib.php");
main();
?>
....?
How does that need updating?
--
__________
|im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply. | | |
P: n/a
|
Chris Hope
Tim Tyler wrote:
[color=blue]
> Doesn't using auto_prepend require php.ini/httpd.conf access[/color]
No, you can use .htaccess files.
[color=blue]
> and affect *everything*?[/color]
Yes.
--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/ | | |
P: n/a
|
Tim Van Wassenhove
In article <I5B2J4.Mn0@bath.ac.uk>, Tim Tyler wrote:[color=blue]
> Tim Van Wassenhove <euki@pi.be> wrote or quoted:[color=green]
>> In article <I59pBA.1pM@bath.ac.uk>, Tim Tyler wrote:[/color]
>[color=green][color=darkred]
>> > It is good - but AFAICS, the arguments given against front controllers
>> > in it are hogwash.
>> >
>> > The main objections are:
>> >
>> > ``In the simple example above, that may not seem like a problem, but what
>> > about when you have hundreds of Page Controllers? You end up with a
>> > massive switch statment or perhaps something disguised in an array, an
>> > XML document or whatever. For every page request, PHP will have to
>> > reload a bunch of data which is irrelevant to the current request the
>> > user is trying to perform.''
>> >
>> > This is fundamentally the same task a webserver performs when looking up a
>> > file in a filing system. If PHP is doing the task, the webserver
>> > doesn't have to. It might be a bit slower in PHP than in C - but
>> > that's hardly a reason for not doing it in PHP.[/color]
>>
>> The fileserver has to do a lookup anyways, to map the request to the
>> controller script.[/color]
>
> Examine the work it has to do - depending on the structure of the
> filing system. The fewer files, the less work.[/color]
The fewer lookups, the less work.
request -> lookup controller script by webserver -> lookup other script
by controller ->
vs
request -> lookup other script by webserver
[color=blue]
>[color=green]
>> In the case you want to have some code that is executed
>> in every script you can also consider using the auto_prepend and
>> auto_append functionality php has.[/color]
>
> Doesn't using auto_prepend require php.ini/httpd.conf access - and affect
> *everything*?[/color]
It only works for the directory where you request it (and for the
directories under it)
[color=blue]
> It doesn't make much difference - the main issue here - IMO - is whether
> the site is in the filing system or the database.
>[color=green]
>> My conclusion: The added value of a controller is 0. Not even
>> mentionning that the chances for introducing bugs in your request->page
>> mapper. Where the code in your webserver has been tested many times
>> before.[/color]
>
> Why can't a front controller be "tested many times before"?
> Code can be shared. Not everyone has to reinvent the wheel.[/color]
But the code in apache has already been tested many times before. And i
have a good feeling it has been tested many more times than whatever
controller script. Yes, i agree on not reinventing the wheel.
[color=blue][color=green][color=darkred]
>> > Everything should go into a database.[/color]
>>
>> Imho, a file system is a database.[/color]
>
> It is.
>
> It is a crappy one, with poor versioning, searching, filtering and sorting
> facilities.[/color]
Depends on the filesystem you are using, and what your requirements are.
Personally i like the article: http://www.namesys.com/whitepaper.html
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info> | | |
P: n/a
|
grz02
Great thanks to all who responded!
Was very interesting reading for me with
discussion, links and thought-food....
Just some clarification...
[color=blue]
>With Apache you can have a URL that says
> www.site.com/page256.php?arg1=foo&arg2=bar and it will go straight to the
>requseted page. Using http://www.site.com/index.php?page=2...1=foo&arg2=bar
>means that everything has to go through index.php first, and index.php must
>then contain code to redirect to page256.php. Not only is this an unecessary
>overhead, it also means that every time you change your application you must
>remember to update index.php.[/color]
No, that wasnt what I meant. There would be no scriptfile, page256.php, at all.
My idea was that the whole HTML-page would be generated on-the-fly
by the "engine" from the URL-arguments and the db-contents,
where you can store both the site-contents, and style information.
Some performance penalty, of course, to generate everything on the fly,
but if you dont expect the trafficload to be much of a concern...
I guess my basic attraction to this approach, is that once the engine is
debugged and working, you shouldnt have to change the code very often
-- but maybe I am dreaming again, perhaps :)
The database, consisting of something like one set of tables for the contents,
and another set of table for design-parameters, styles, etc,
and mappings between them
would then be more flexible and easier to maintain,
than a growing set of scriptfiles with a mix of HTML,
PHP, CSS and db-calls in them.
Of course, the main challenge of this approach, however, is how to design the
database in a good way, to allow you to FULLY DESCRIBE your whole site.
But I was actually having the idea (or dreaming) that somebody most likely
already had done all that work, and released it as a useful product.
[color=blue]
>... Imho, a file system is a database.[/color]
Well... kind of... but a very simple special-case,
something like a db with only one table in it:
create table filesys
(
directory char(1024),
filename char(256)),
filecontent blob
);
I figure, however, there must be something more to db:es than this,
both from my personal experience, plus I heard they have become pretty
popular gadgets in today's business world, too ;)
Regards, | | |
P: n/a
|
Joep
Very interesting, especially when considering maintainability. I would like
to have the information on one hand and layout on the other without
cluttering up my fs. Nice ideas! | | |
P: n/a
|
Tim Van Wassenhove
In article <1641ee43.0410090244.5cf2ef4f@posting.google.com >, grz02 wrote:[color=blue]
> Great thanks to all who responded!
>
> Was very interesting reading for me with
> discussion, links and thought-food....
>
> Just some clarification...
>[color=green]
>>With Apache you can have a URL that says
>> www.site.com/page256.php?arg1=foo&arg2=bar and it will go straight to the
>>requseted page. Using http://www.site.com/index.php?page=2...1=foo&arg2=bar
>>means that everything has to go through index.php first, and index.php must
>>then contain code to redirect to page256.php. Not only is this an unecessary
>>overhead, it also means that every time you change your application you must
>>remember to update index.php.[/color]
>
> No, that wasnt what I meant. There would be no scriptfile, page256.php, at all.
> My idea was that the whole HTML-page would be generated on-the-fly
> by the "engine" from the URL-arguments and the db-contents,
> where you can store both the site-contents, and style information.
>
> Some performance penalty, of course, to generate everything on the fly,
> but if you dont expect the trafficload to be much of a concern...[/color]
But what are the gains from it when it's stored in a RDBMS instead of the
filesystem?
[color=blue]
> I guess my basic attraction to this approach, is that once the engine is
> debugged and working, you shouldnt have to change the code very often
> -- but maybe I am dreaming again, perhaps :)[/color]
Well, most filesystems already do work quite good. So if you use that,
you don't have to write the code (and/or debug).
[color=blue]
> The database, consisting of something like one set of tables for the contents,
> and another set of table for design-parameters, styles, etc,
> and mappings between them
> would then be more flexible and easier to maintain,
> than a growing set of scriptfiles with a mix of HTML,
> PHP, CSS and db-calls in them.[/color]
Why would the grow more/less fast in a dbms than in a filesystem??
[color=blue]
> Of course, the main challenge of this approach, however, is how to design the
> database in a good way, to allow you to FULLY DESCRIBE your whole site.[/color]
It is about designing your code/website in a good way. No matter where
the code for it will be stored.
[color=blue][color=green]
>>... Imho, a file system is a database.[/color]
>
> Well... kind of... but a very simple special-case,
> something like a db with only one table in it:
>
> create table filesys
> (
> directory char(1024),
> filename char(256)),
> filecontent blob
> );[/color]
Actually, i think most filesytems (in use nowadays) map better to the hierarchical or the
network model than the relational model.
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info> | | |
P: n/a
|
Christian Fersch
grz02 wrote:[color=blue]
> I guess my basic attraction to this approach, is that once the engine is
> debugged and working, you shouldnt have to change the code very often
> -- but maybe I am dreaming again, perhaps :)
>
> The database, consisting of something like one set of tables for the contents,
> and another set of table for design-parameters, styles, etc,
> and mappings between them
> would then be more flexible and easier to maintain,
> than a growing set of scriptfiles with a mix of HTML,
> PHP, CSS and db-calls in them.
>
> Of course, the main challenge of this approach, however, is how to design the
> database in a good way, to allow you to FULLY DESCRIBE your whole site.
>
> But I was actually having the idea (or dreaming) that somebody most likely
> already had done all that work, and released it as a useful product.[/color]
That is useless. Of course it could be done, but it a lot more
effective, to customize the script to the site, than having that big
overhead (not only in speed, but also in code-lines and debugging time)
of beeing able to create a _whole site_ dynamically.
And that exists - it's called a cms and there are thousands of that kind
out there.
I have one running myself: http://www.cyberpunkuniverse.de/sitemap.htm
This wohle tree is stored in one database-table. I use some apache
tricks, to get those nice urls - the number-dir is the only interessting
part of the url, which is the id in my db-table.
I'm working on a modularity, so that the news and image galleries can be
put into that tree. Is this what you ment, or did I completely miss your
point?
[color=blue]
> I figure, however, there must be something more to db:es than this,
> both from my personal experience, plus I heard they have become pretty
> popular gadgets in today's business world, too ;)[/color]
Well, you can do everything with PCs. It is possible to write a script,
that will allow your whole website to be managned via web-interface
(even the design could be changed via web-interface), and a lot more,
but this just isn't worth the time writing it, for it can allready be
done. Maybe not as fast, but the time needed to write such a script
won't be compensated by that.
Greetings, Christian. | | |
P: n/a
|
Tony Marston
"Tim Tyler" <tim@tt1lock.org> wrote in message news:I5B2ww.My9@bath.ac.uk...[color=blue]
> Tony Marston <tony@nospam.demon.co.uk> wrote or quoted:[color=green]
>> "Tim Tyler" <tim@tt1lock.org> wrote in message
>> news:I59pBA.1pM@bath.ac.uk...[color=darkred]
>> > grz02 <grz01@spray.se> wrote or quoted:[/color][/color]
>[color=green][color=darkred]
>> >> I can also envision a design where, even if the website contains
>> >> a huge number of pages and different functions,
>> >> there would actually only be a single PHP-script "index.php"
>> >> and all sub-pages are generated on-the-fly, from arguments
>> >> in the URL, i.e. all URLs simply looking like:
>> >>
>> >> index.php?pageid=1
>> >> index.php?pageid=2
>> >> ...
>> >> index.php?pageid=productlist
>> >> index.php?pageid=registration
>> >> index.php?pageid=loginform
>> >> index.php?pageid=contactform
>> >>
>> >> etc...
>> >>
>> >> The index.php startfile might only look something like:
>> >>
>> >> <html>
>> >> <php?
>> >> include("lib.php");
>> >> main();
>> >> ?>
>> >> </html>
>> >
>> > That's called a "front controller".
>> >
>> > http://www.phppatterns.com/index.php...leview/81/1/1/
>> >
>> > ...is an article about front controllers in PHP.
>> >
>> > It is good - but AFAICS, the arguments given against front controllers
>> > in it are hogwash.[/color]
>>
>> No they're not. IMHO they are perfectly sound. Front controllers were
>> designed for languages such as Java which have web servers which behave
>> differently to Apache. With Apache you can have a URL that says
>> www.site.com/page256.php?arg1=foo&arg2=bar and it will go straight to the
>> requseted page. Using http://www.site.com/index.php?page=2...1=foo&arg2=bar
>> means that everything has to go through index.php first, and index.php
>> must
>> then contain code to redirect to page256.php.[/color]
>
> You are complaining about the performance cost of reading a file like:
>
> <php?
> include("lib.php");
> main();
> ?>
>
> ...from the server?
>
> For those anal about performance, that seems to be more than compensated
> for by the lack of a need to include:
>
> include("header.php");
> ...
> include("footer.php");
>
> ...in every single page - and besides, that file should get cached and
> ought to take practically no time to read.[/color]
I can achieve the functionality I require without header.php and footer.php.
[color=blue][color=green]
>> Not only is this an unecessary overhead, it also means that every time
>> you change your application you must remember to update index.php.[/color]
>
> When index.php looks like:
>
> <php?
> include("lib.php");
> main();
> ?>
>
> ...?
>
> How does that need updating?[/color]
If every request for a page starts off by going through index.php then it
has to be redirected to the correct page, so index.php has to have knowledge
of every page in the system so it can redirect to that page. This means that
every time you add or remove a page you have to update index.php. In your
example the cross reference between request and script may exist in lib.php,
but that is the same difference - there is still a single place that needs
updating each time you change a page.
That's why I think front controllers are inferior to page controllers.
--
Tony Marston http://www.tonymarston.net | | |
P: n/a
|
Tony Marston
"Tim Tyler" <tim@tt1lock.org> wrote in message news:I5B2J4.Mn0@bath.ac.uk...[color=blue]
> Tim Van Wassenhove <euki@pi.be> wrote or quoted:[color=green]
>> In article <I59pBA.1pM@bath.ac.uk>, Tim Tyler wrote:[/color]
>[/color]
<snip>
[color=blue][color=green][color=darkred]
>> > Everything should go into a database.[/color]
>>
>> Imho, a file system is a database.[/color]
>
> It is.
>
> It is a crappy one, with poor versioning, searching, filtering and sorting
> facilities.[/color]
Storing code in a database does not automatically provide any of those
features. You still have to write them, just as you can for files in a file
system.
--
Tony Marston http://www.tonymarston.net | | |
P: n/a
|
Tim Tyler
Chris Hope <blackhole@electrictoolbox.com> wrote or quoted:[color=blue]
> Tim Tyler wrote:[/color]
[color=blue][color=green]
> > Doesn't using auto_prepend require php.ini/httpd.conf access[/color]
>
> No, you can use .htaccess files.[/color]
Many service providers disable that for security reasons.
Write code that depends of this sort of thing and many customers will
be unable to run it.
--
__________
|im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply. | | |
P: n/a
|
Tim Tyler
Tony Marston <tony@nospam.demon.co.uk> wrote or quoted:[color=blue]
> "Tim Tyler" <tim@tt1lock.org> wrote in message news:I5B2J4.Mn0@bath.ac.uk...[color=green]
> > Tim Van Wassenhove <euki@pi.be> wrote or quoted:[color=darkred]
> >> In article <I59pBA.1pM@bath.ac.uk>, Tim Tyler wrote:[/color][/color][/color]
[color=blue][color=green][color=darkred]
> >> > Everything should go into a database.
> >>
> >> Imho, a file system is a database.[/color]
> >
> > It is.
> >
> > It is a crappy one, with poor versioning, searching, filtering and sorting
> > facilities.[/color]
>
> Storing code in a database does not automatically provide any of those
> features. You still have to write them, just as you can for files in a file
> system.[/color]
There are quite a number of searching filtering and sorting facilities
built into databases and made available via the SQL language.
Databases typically have better facilites for grouping actions, undoing
them and making backups, as well.
Filing systems are primitive databases - too primitve for many
applications these days - and a lot of data is migrating into
databases, to provide better searching, indexing, filtering
and sorting facilities.
--
__________
|im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply. | | |
P: n/a
|
grz02
Thanks Christian.
CMS here stands for what?
/grz
Christian Fersch <Chronial@web.de> wrote in message news:<ck8i9d$2m6$01$1@news.t-online.com>...
[color=blue]
>Of course it could be done, but it a lot more
>effective, to customize the script to the site, than having that big
>overhead (not only in speed, but also in code-lines and debugging time)
>of beeing able to create a _whole site_ dynamically.[/color]
[color=blue]
>And that exists - it's called a cms and there are thousands of that kind
>out there.
>I have one running myself:
> http://www.cyberpunkuniverse.de/sitemap.htm[/color]
[color=blue]
>This wohle tree is stored in one database-table.[/color] | | |
P: n/a
|
Tim Tyler
Tony Marston <tony@nospam.demon.co.uk> wrote or quoted:[color=blue]
> "Tim Tyler" <tim@tt1lock.org> wrote in message news:I5B2ww.My9@bath.ac.uk...[/color]
[color=blue][color=green]
> > You are complaining about the performance cost of reading a file like:
> >
> > <php?
> > include("lib.php");
> > main();
> > ?>
> >
> > ...from the server?
> >
> > For those anal about performance, that seems to be more than compensated
> > for by the lack of a need to include:
> >
> > include("header.php");
> > ...
> > include("footer.php");
> >
> > ...in every single page - and besides, that file should get cached and
> > ought to take practically no time to read.[/color]
>
> I can achieve the functionality I require without header.php and footer.php.[/color]
This still seems like an anal performance niggle. Such issues are
way below my threshold of what's important when designing sites.
What I care about are things like time-to-market and rapid development -
not whether it takes 433 or 440 ms to render a page.
You should not make a mess of your architecture for the sake of a
few milliseconds - that's called premature optimisation.
[color=blue][color=green][color=darkred]
> >> Not only is this an unecessary overhead, it also means that every time
> >> you change your application you must remember to update index.php.[/color]
> >
> > When index.php looks like:
> >
> > <php?
> > include("lib.php");
> > main();
> > ?>
> >
> > ...?
> >
> > How does that need updating?[/color]
>
> If every request for a page starts off by going through index.php then it
> has to be redirected to the correct page, so index.php has to have knowledge
> of every page in the system so it can redirect to that page.[/color]
....or have access to that knowledge.
[color=blue]
> This means that every time you add or remove a page you have to update
> index.php.[/color]
No - not if it has access to the information. The information is
presumably also stored in a database - and updates itself automatically
when new pages are created - so there need not be any maintenance
issue involved.
[color=blue]
> In your example the cross reference between request and script may
> exist in lib.php, but that is the same difference - there is still a
> single place that needs updating each time you change a page.[/color]
Creating a page involved modifying the database. That would automatically
update the list of available pages.
--
__________
|im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply. | | |
P: n/a
|
Tim Tyler
Tim Van Wassenhove <euki@pi.be> wrote or quoted:[color=blue]
> In article <I5B2J4.Mn0@bath.ac.uk>, Tim Tyler wrote:[color=green]
> > Tim Van Wassenhove <euki@pi.be> wrote or quoted:[color=darkred]
> >> In article <I59pBA.1pM@bath.ac.uk>, Tim Tyler wrote:[/color][/color][/color]
[color=blue][color=green][color=darkred]
> >> > It is good - but AFAICS, the arguments given against front controllers
> >> > in it are hogwash.
> >> >
> >> > The main objections are:
> >> >
> >> > ``In the simple example above, that may not seem like a problem, but what
> >> > about when you have hundreds of Page Controllers? You end up with a
> >> > massive switch statment or perhaps something disguised in an array, an
> >> > XML document or whatever. For every page request, PHP will have to
> >> > reload a bunch of data which is irrelevant to the current request the
> >> > user is trying to perform.''
> >> >
> >> > This is fundamentally the same task a webserver performs when looking up a
> >> > file in a filing system. If PHP is doing the task, the webserver
> >> > doesn't have to. It might be a bit slower in PHP than in C - but
> >> > that's hardly a reason for not doing it in PHP.
> >>
> >> The fileserver has to do a lookup anyways, to map the request to the
> >> controller script.[/color]
> >
> > Examine the work it has to do - depending on the structure of the
> > filing system. The fewer files, the less work.[/color]
>
> The fewer lookups, the less work.[/color]
As a generalisation, this is false. The lookups can take different
quantities of work, and it is not always true that more looksups take
more work.
Another determiner of performance is how many alternatives have to
be searched throuh. Basically:
index.php?foo/bar/zub
....and...
foo/bar/zub/index.php
....takes the came work to parse as and resolve - since the same number of
alternatives need to be considered and searched throuh.
One is being searched in compiled C and the other one is being done
in PHP - and there /will/ be a speed difference there.
If performance is your overriding concern, then indexing files is
likely to be faster than accessing a database. That's a pretty
crummy argument for using flat files in this day and age, though.
If you want things to go faster, spend more on hardware - don't
bend your application framework out of shape for the sake of a
few milliseconds.
[color=blue][color=green][color=darkred]
> >> My conclusion: The added value of a controller is 0. Not even
> >> mentionning that the chances for introducing bugs in your request->page
> >> mapper. Where the code in your webserver has been tested many times
> >> before.[/color]
> >
> > Why can't a front controller be "tested many times before"?
> > Code can be shared. Not everyone has to reinvent the wheel.[/color]
>
> But the code in apache has already been tested many times before. And i
> have a good feeling it has been tested many more times than whatever
> controller script. Yes, i agree on not reinventing the wheel.[/color]
An argument against not writing a front controller yourself.
It's not exactly rocket science, though. You are only looking
up a script from a query string. Is that code going to need
weeks of testing before you get it right? Also, front controllers
are not exactly new either. There are plenty of them out there -
many already pretty well tested.
[color=blue][color=green][color=darkred]
> >> > Everything should go into a database.
> >>
> >> Imho, a file system is a database.[/color]
> >
> > It is.
> >
> > It is a crappy one, with poor versioning, searching, filtering and sorting
> > facilities.[/color]
>
> Depends on the filesystem you are using, and what your requirements are.
> Personally i like the article: http://www.namesys.com/whitepaper.html[/color]
It seems to agree that most filing systems are impoverished and need
replacing.
--
__________
|im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply. | | |
P: n/a
|
Henk Verhoeven
Hi grz,
This is a lot of questions/ideas/requirements. We have developed an open
source framework for development of web based applications. It is called
phpPeanuts. It seems to be close to some of your ideas but quite far
from others. This has to do with design choices we made. I will begin
with the similarities, then go into the differences.
[color=blue]
> I can also envision a design where, even if the website contains
> a huge number of pages and different functions,
> there would actually only be a single PHP-script "index.php"
> and all sub-pages are generated on-the-fly, from arguments
> in the URL, i.e. all URLs simply looking like:
>
> index.php?pageid=1
> index.php?pageid=2
> ...
> index.php?pageid=productlist
> index.php?pageid=registration[/color]
Something like that yes:
index.php?pntType=Product&pntHandler=EditDetailsPa ge&id=1
The index.php script will give you a form for editing the Product with
id = 1. Or more precise, it will probably include the file that contains
the class ObjectEditDetailsPage, instantiate it and forward it the
request*. ObectEditDetailsPage will use its inherited function
getRequestedObject() to obtain an instance of the class Product with id
= 1, and generate and output a form for displaying and editing its
properties. The form may be generated entirely from metadata. No need to
have a database with forms. No boring designing forms for Product,
Customer, Order, Shipment and all those other types you need. Just one
single generic site design. Then if you specify the metadata in the
Product class, the rest done is automaticly.
As you see our aproach is object oriented. This means that we do not
have a big pile of functions in which an engine is implemented, that
processes passive data from a database. We rather have an assembly of
objects that cooperate to do the work. Objects combine functions and
data. This makes them much more flexible then just trying to represent
the entire website desing in data (like your design seems to do) or in
functions (like standard php scripting tends to do).
With object orientation it is possible to offer the developer a default
user interface for his application, and at the same time to allow the
developer to specialize allmost any aspect of both the engine and the
design by creating subclasses and overriding some methods. Because the
methods are written in php, he can put in any code he likes, so he is
not limited to what the existing engine can do.
Like with most traditional IDE's, the user interface is composed from
objects, like listboxes, tables, buttons, dialogs, etc. Only the
phpPeanuts objects do not exist in the client PC and draw on the screen,
but rather exist on the server, process requests and output HTML. For
lists of user interfacing classes by category see http://www.phppeanuts.org/site/index...t.web/web.html
Of course there is still a need for a place to put pieces of HTML that
hold parts of the design. We could have stored them in the database, or
use a template enigine, but we chose 'the simpelest thing that could
possibly work': php include files. These have the advantage that you can
include pieces of php to call methods. See http://www.phppeanuts.org/site/index...principle.html
for how all this fits together.
But if you like it better to have a database, be my guest: make some
subclasses, override the methods that currently do the inclusion and
fetch and interpret your design data from there... (actually you may hit
a design limitation here, or maybe it has already been solved. Anyhow,
if you explain how our design limits you you to specilize the framework
in the way you need to, we will be happy see if we can make the
necessary adaptations)
[color=blue]
> and you can code "event" pieces of code
> that will react to clicks, buttons and user-actions like
> in the traditional IDE:s.[/color]
We do in specific situations support event handler methods. However,
http works with url's, requests and pages that are returned. So our user
interfacing framework focusses on handling requests and composing pages
and forms. Only where the composition needs to be specialized in
repeated details you will need to implement event handler methods.
Otherwise it is a matter of specializing classes that becuase they exist
override the defaults and override methods.
We do not support IDE style WYSIWYG graphically editing a user
interface. In an earlier version of the framework (in Java) we had an
template technique for this, but even with dreamweaver it proved to be a
lot of work to manually desing the user interface of a substantial
application. The problem was a lack of abstraction. The result wass lots
of replication, little reuse. We tried to make our objects editable with
dreamweaver, but that was too cumbersome. Existing WYSIWYG editors
simply could not cope with the dynamics of objects. (For some reason
none of them supported the JavaBeans standard the way IDE's do).
It would still be nice to have a way to WYSIWIG edit the bits and pieces
of html the design is composed from. Preferably i would have that in the
browser, as part of the working application. But building that is a huge
effort, and the more we can reuse pieces of design, the less we can gain
from it. But if anyone has substantial leftover money i would be happy
to look into it
I guess this is the basic difference between traditional IDE's and
phpPeanuts: IDE's try to facilitate graphical designing and coding. We
build components and try to faciltate their reuse. The more you can
reuse, the less design and code you need for the same end user function.
We believe that in the long run this gives a higer productivity then
traditional IDE's and results in more flexible applications, in the
sense of easyer to adapt to new or changing requirements.
Greetings,
Henk Verhoeven, www.phpPeanuts.org.
* The mapping of urls to objects is called Request Dispatch and it is
acutally a bit more complicated, see http://www.phppeanuts.org/site/index...+dispatch.html | | Post your reply Help answer this question
Didn't find the answer to your PHP question?
You can also browse similar questions: PHP | | Question stats - viewed: 1928
- replies: 43
- date asked: Jul 17 '05
|