PHP Front Controller

Hi everyone,
I have a bit of a convoluted question here.  I'm designing a site using the book "PHP 5 Social Networking" by Michael Peacock.  Unfortunately there are numerous problems with the code, I have checked the forums related to the book and there doesn't seem to be much corrected information.  I'd like to modify the code as well, as I would prefer the addresses in a different format.  One problem that is occurring is that it is using a front controller and when an internal link is clicked it works fine as long as it doesn't involve multiple folders, e.g.  if you're at the site root and click on members the link is site/members, and when you click on login it is site/authenticate/login, but then if you click members after that it's site/authenticate/members.  I would actually prefer the username after the site URL, such as site/username.  I'm understanding most of the code, but just these couple bits are driving me crazy.  I'm probably not putting enough information in here and along with the attachment, so just let me know if there is anything else you need to know.  Thanks in advance.

PS My test server is Apache and I have added the following to the httpd file:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]
</IfModule>
PHP-Front-Controller-Code.zip
William-BAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Eddie ShipmanAll-around developerCommented:
Well, the code you posted in the zip file is incomplete and there is no way to determine the cause of the problem.

I was able to download the whole code from the book but it is some terrible code, for sure.
I will see if I can figure out what is going on.

What chapter code are you using?
0
William-BAuthor Commented:
I'm using the chapter 11 code.  I had been trying to use the code from the earlier chapters but it wasn't working.  I was using the later code just in case a problem was corrected later on.  Sorry about the code, I tried to include the major portions without having to resort to adding all the template files.
0
Eddie ShipmanAll-around developerCommented:
It is rather disheartening to me that Packt would release a publication with code that is so buggy. They usually have very good technical editors that go over the code to make sure it works.

I will see what I can do.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

William-BAuthor Commented:
Thank you very much.  I appreciate it.  I had been going through it wondering what I was doing wrong.  It's nice to know that it might not be all my errors.
0
William-BAuthor Commented:
Hi All,
I'm not sure if you got around to looking at the code, Eddie, but I have been playing around with it some more.  I don't know if this relates to the structure of the front controller but it is performing a request for every file that gets included, i.e. both the css file and the logo.  Unfortunately it doesn't look like the front controller is processing either one since for the css file it just returns the whole html document instead of just the css formatting.  I checked this out with Firebug and with a page like MSN I'll see the actual formatting layup but with my test page it actually has a response that is identical to the html tab.  Not sure if you need some more information on this, but just thought I'd throw it out there.
Thanks.
0
Eddie ShipmanAll-around developerCommented:
Well, personally, I'd dump this book and learn Yii or Kohana as they are MVC frameworks that are MUCH better than the one that is in the book.

They are very easy to understand and you should have no trouble converting the concepts from the book to their framework.

I was very busy last weekend so I was not able to get to it but I might look at converting the code to Yii since it is so easy to develop with.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
William-BAuthor Commented:
Well that's a bummer.  I had a bit higher expectations for the book.  Thanks for looking into it for me though.
0
Eddie ShipmanAll-around developerCommented:
So do you want to convert it?
0
William-BAuthor Commented:
Yeah I'm in the process of moving it to Kohana.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.