Jump to content

Recommended Posts

Ok,

 

When I create a site I open a basic template that I have created that consists of a css file an index page and a few php inserts for the header, nav and footer.

 

It works fine and I am happy with it but I keep seeing posts / comments on the net saying that all websites should be dynamically loaded etc and all content on pages should be database driven, so on and so on.

 

How does everyone else setup a basic site. I dont want to use a CMS like wordpress or joomla. I looked into CakePHP but apparently you should not use it unless you are creating a blog, forum etc. Here I was thinking CakePHP was a basic sort of framework that you can add features to.

 

I need help deciding the best way to do things, I have created sites that pull info from databases before but it was still all hand coded.

 

Help from anyone expereinced in this topic is very much needed

Link to comment
https://forums.phpfreaks.com/topic/179263-am-i-setting-up-my-sites-oldschool/
Share on other sites

you need to develop an MVC or use one,

 

you create a databse model and then a view and then you controle the actions of the viw via a controller method these are three different objects.

 

use zend framework

 

framework.zend.com

Thanks, is it a steep learning curve. Also are there any limitations to what you can do with a database model instead of normal hand coding?

 

no there are no limits,

 

you just need to learn how to hook up the db into the config

 

then use the sqlqueries using the model objects prepared statements which also have left join etc,

 

you can also do pure sql but thats not recommended as its easily injectable.

 

theyhave a registry like object available everywhere into it you can put there ACL object and create access control by querying the acl

 

they also have a handy authenticator class.

 

urls are mod rewritten

 

all u say to go is

 

controler/method

 

or if you have a module folder it would be module/controler/method

 

you would then create a view for that method into which you can retrieve vars from the controler so method_view is the next file

they give you the entire directory structure wired up and ready to go with test files and config etc then do teh tutorial

 

also for your front end you might like to use ExtJS goes well with zend mod rewrite as its pure ajax based interface the urls fit in nicley and make sense module/controler/method str8 into a front end wdget will get all the data for that widget to work with

Thanks for all the advice but everything you just said is over my head.

 

It sounds pretty full on. So should I be using an MVC even for a basic site with text, images, a gallery and contact forms?

 

It sounds like it would take me longer to do it through an MVC or is it actually quite fast once setup? That' s another thing, is creating a layout the same, do I still have basic css files etc.

 

Do I end up having sepereate php files for each page or is there just one page with the content changing dynamically.

 

I guess I just want a very basic overview of how it works, in idiots terms, so I can decide if it is the track I want to take... if that's possible  ;)

You can build and Million+ page site with a few lines a code, include the header and footer and your done. Of course this doesnt mean all your urls will be the same, make them dynamic with 1 line of htaccess :

 

RewriteRule ^view=(.*) view.php?id=$1  [L,QSA]

 

 

 

 

I did not want to use cms like Wordpress or Joomla neither, I make my websites from scratch.

Its not that hard to make a simple website that pulls up your content from a DB. Create a database and create a table that holds some stuff like the id, title, body.

 

Then create page thats using something like fckeditor and you post to it, and then create a php file to take the post and insert into the database. Then create a file called like article.php and it takes a $_GET like  aritcle.php?id=1, which then you grab the stuff in the database where the incrementing ID = 1, then you put the details into the page. For basic concept its really that simple. Except next you will probably want to protect the file with a login and create some more stuff that allows you edit a existing article or save it as  draft and also delete article and maby create some categories and recursively name them threw another table that hold a number and a name while the article table will hold just the number. blah blah, its kinda complicated  with all the small details. But its really not complicate just get few thousand lines of code it should take more the 8-10Hrs a day for a week. xD

:smoker:

 

Thanks a lot for your help guys.

 

It sounds like I should give it a go. Keldorn, I didn't quite get that last part of your post... were you meaning that to do the equilivant by hand coding it would take 8-10 hours for a week or were you saying it would take that long with Zend.

 

Also on that note what would you all recommend to use as an MVC?

 

I have heard that Symfony is good and also CakePHP. Or is Zend the king of the roost when it comes to this?

You don't HAVE to use the MVC design pattern but it would appear to be the most popular with existing frameworks*. There are a number of others such as the factory pattern and the singleton pattern (see here for other examples). 

 

I don't know enough about the common frameworks to comment on which is best but if a framework is the way you want to go there are a number of reviews on the most common ones so I guess it would be like anything else. You choose one that best suits your needs. Personally I use a tiered(?) approach.

 

I use ADODB to manage database access and the actual code for the content is placed in one of two folders. Depending on if it is part of the core application or an optional addon. I then have a basic theme option that uses a single html template and a css file to manage the layout. Personally I'd say it was a 2 tier system but it works quickly, doesn't take up alot of space and whilst not perfect, it is easy to maintain and I try to keep it as loose as possible. Which I believe is the overall goal. Re-useable and adaptable code.

 

* not researched this so it is just my perspective. Feel free to correct me on this or indeed any other points I may have got wrong.

in my new company we use an inhouse developed mvc, and sadly to say its a lower level version of the zend framework, you dont need to use an mvc but if you do it will benifit your skill and further development, things wont get out of hand.

Not all sites fit a dynamic model... use frameworks and database driven back-ends when the situation calls for it.

 

If you are going to create 5 pages, load some content that might change once every 6 months, then just build it static. There isn't much reason for all of the overhead unless it is really needed.

 

 

I have to agree with MatthewJ,

Unless someone can tell me why I must add adding a database driven CMS to a single page website with interactive a flash movie...

 

of course theirs benefits to adding it but theirs benefits to not adding it.

 

simply put, if you have a HTML website that doesn't support any programming languages then its going to be cheaper,

But lets add some PHP.. now you need to worry about apache and PHP (if one breaks your site goes down).. also we need to look closer and security..

 

okay now add MySQL.. now you need to worry about apache, PHP and MySQL (if one breaks your site goes down).. also we need to look even closer and security... lets add SQL injection to the mix..

 

Also you don't need to use a framework (of course theirs benefits to using them) you could create a simple PHP script that echo's the results from a SQL table (like in keldorn post)

Not all sites fit a dynamic model... use frameworks and database driven back-ends when the situation calls for it.

 

If you are going to create 5 pages, load some content that might change once every 6 months, then just build it static. There isn't much reason for all of the overhead unless it is really needed.

 

 

 

absolutly right,

 

a header.php footer.php

 

and some database entity models classes

 

eg user class wich embodies selectall and update add etc which can easily be coppied changed to encapsulate a new entity eg products.

 

thats about as advanced you need to go for a good CMS

 

and a config file.php

in my new company we use an inhouse developed mvc, and sadly to say its a lower level version of the zend framework, you dont need to use an mvc but if you do it will benifit your skill and further development, things wont get out of hand.

 

You cannot develop/create/use MVC. It's a proper noun, a name of a particular design pattern.

 

I have to agree with MatthewJ,

Unless someone can tell me why I must add adding a database driven CMS to a single page website with interactive a flash movie...

 

The model in MVC doesn't refer to a database or database access object (otherwise we would just call it MDC or whatever). The model is the domain-specific representation of the data you're working with. You always have some sort of data because otherwise you cannot have any output.

 

You don't HAVE to use the MVC design pattern but it would appear to be the most popular with existing frameworks*. There are a number of others such as the factory pattern and the singleton pattern (see here for other examples).

 

The factory and singleton patterns are creational patterns while MVC is an architectural pattern. You cannot compare factory/singleton with MVC the same way you cannot compare a car to an apple.

In case their was confusion my past post was referring to this comment

I keep seeing posts / comments on the net saying that all websites should be dynamically loaded etc and all content on pages should be database driven, so on and so on.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.