On 16 August 2011 09:53, Dajka Tamás <vi...@vipernet.hu> wrote:
> Hi,
> Surely there's a wiki/doc somewhere :)
> But for the start:
> 1) plan what exactly you want to accomplish ( functionality )
> 2) complexity
>        - if simple, just throw it in one php ( like index.php )
>        - if more complex, you can separate the pages and/or use classes
> 3) based on 2), plan the structure ( I'm using mostly one entry point - 
> index.php - with classes, templates, files included, since I like things 
> separated )
> Some thing you should not forget:
> - whole webapp thing is event based ( client will do something - press a link 
> - and the server will react ) - the connection is not maintained all the time
> - PHP is server side (harder to debug), you cannot do anything on client side 
> ( just push what to display ) ( JS is client side )
> - you can start the session whenever you want ( it's nearly the first line of 
> my app ), but you should control the access with variables, like if ( 
> $_SESSION['uid'] ) or if ( $_SESSION['loggedin'] )
> - most webservers interprets things between <?php ?> even if the file name 
> ends with .htm or .html
> - for JS and connection related things FireBug for FireFox is a good idea ( 
> you can track, what's submitted, etc )
> What I'm liking:
> - one entry point ( index.php )
> - sub-pages, are separate php/template pairs BUT are included from index.php 
> ( after access verification, etc )
> - nearly all the functions are put in separate classes ( like user.class.php 
> for user related things - login,logout, etc )
> - using a template engine is not a very bad idea ( like Smarty ), you can 
> separate the real code from html, which make debugging easier - at least for 
> me :)
> BTW, take a look on some free stuff. You can always learn from others. There 
> are some good ideas in open CMS systems, like Joomla.
> Cheers,
>        Tom
> -----Original Message-----
> From: Andreas [mailto:maps...@gmx.net]
> Sent: Tuesday, August 16, 2011 12:39 AM
> To: php-general@lists.php.net
> Subject: [PHP] Newbie question. What is the best structure of a php-app?
> Hi,
> I'm fairly new to PHP but not to programming as such. Currently I sat up
> XAMPP with xdebug, Netbeans and Eclipse to get a feeling.
> I can write and run php-files but I am wondering how I should construct
> a more complex application that runs over several pages between a login
> and a logout.
> How would I structure such an application so that it is possible to run
> it in the debugger from the beginning?
> E.g. as a simple example I may build an index.html that has a menue with
> links to 3 php-files.
> 1)   login.php
> 2)   enter_data.php
> 3)   list_data.php
> as html-links within an ul-list.
> The user should at first click on login where user/password gets entered
> an a session starts.
> Then the application comes back to index.html.
> Now he might click 2) ...
> Is it possible to run the whole application from the start on?
> index.html is no php so xdebug won't process it and therefore the IDEs
> may start index.html but can't show the stage where the page is just
> waiting e.g. for a click on "login" and later branch for the other options.
> Even if I write an index.php that shows the menue eventually the script
> just dumps the html that'll wait for the following clicks.
> Those following steps are far more likely in need to be debugged.
> Is it neccessary to debug those subpages separately even though they
> need prior steps like login.php that store some infos in a session or
> cookie that later scripts need to rely on?
> Can I somehow watch what is going on from the index.html on?
> Until now I just found documentation that explains the php language.
> Thats good too but I'd need to get an idea about the "web-app-thinking"
> that consist of just pages where the designer has to hope that the user
> stays within the applicationflow instead of clicking unexpectedly on the
> back-button or just jumping off to some other site if he likes to.
> In contrast to this desktop-apps seem to be less demanding because I
> know where a user can navigate from a certain stage within the app and I
> could step from program start to stop with the debugger if I feel the
> need to.
> Is there a tutorial that explains how to build consistent web-apps
> beyond the details of php language?
> regards...

I like the Zend Framework layout where the class names and file names
are created according to a standard

And by putting the codebase outside of docroot (include_path is your
friend here), you allow the framework to be used on multiple sites on
the same server.

For me, the only things I have in my docroot are statics (css, js,
images, html) and index.php (though occasional one-shot utils will
exist there).

When I develop, I have 3 versions of the site (live, test and dev).
www.site.com, test.site.com and dev.site.com

I have separate SQL Server instances (I'm on Windows and mainly
develop for MS SQL Server - though Mongo and SQLite are now both
becoming an active part of my work).

Keeping everything separate in the three environments allows you to
play to your hearts content (dev), provide a testable app (test) and
an untouched by human hand live site (www).

I also use a tools called SQL Compare and SQL Data Compare from
RedGate (they also have tools for mysql). These allow me to compare my
DB schemas and produce a changeset for the DB, both the schema and the

So, when it comes to upgrading the DB, I compare dev to test and
upgrade test. I log the changeset into my version control system
allowing me to reuse the changeset on the live dbs.

If I need to make more changes to the DB. I issue a new changeset for
those changes. No need to amend the previous changeset.

Does this mean that sometimes I'm rolling back changes? Yes, but I'm
doing so in a controlled and reportable/repeatable manner. No
different to any other VCS.

I hope these points help.


Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to