Klyx99 Posted December 13, 2016 Share Posted December 13, 2016 (edited) I write lots of personal apps. And love writing in PHP/MySQL I decided to make a php app for my biz. Small so didnt think I needed anything fancy. unlike writing apps, php scripts will continue until the page is done (even on a header(location...). I use router pages with includes, and using $_GET as the switch, but that seems to be getting cluttered and not very good. I am currently looking into CakePHP and that is amazing, but trust me when I say, that will be a massive over kill for what I want. in shor, psuedo code below if not logged in, login else check for afk (session var) now with that first line, it can be problematic. because of the following if no customer, search customer, display results(once customer is found, stick in session var) but login is still showing - but if i do the if/then/else it works, however the following will show and now it turns into spaghetti with customer, do something switch ($_GET[somevar])){ option 1: include(this page) option 2: include(thatpage) option 3: include( and the other page) } as you can see, that will turn into a train wreck. for my small web pages - that works fine. now if i switch and have the scrip make new pages, then I break my css layouts. I know some of you ar thinking, what about smarty, that too seems a little more that I want to get into, especially since php works fine I looked at OSS php POS and they are not what I want. it is simple, login, get a customer, store info about them, edit them with work they need done, finalize the ticket. thats it. any suggestions would be great, not looking for a heavy duty app, I am sure I am missing something simple with just php/mysql and I am over looking it. thanks! Edited December 13, 2016 by Klyx99 Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted December 13, 2016 Share Posted December 13, 2016 I've read your post a couple of times, and I'm still not sure what exactly you're asking for. First: If you want to immediately stop the script (e. g. after a redirect), you use an exit statement. However, organizing your router is a different problem and mostly comes down to personal taste. There are essentially three ways how to map URLs to pages: inside your code (not necessarily with a long switch statement, most modern routers use registration functions or methods), inside configuration files (example) or automagically by deducing the filename from some part of the URL (this can be dangerous if done naively). The “pages” themselves can again by implemented in different ways: as separate scripts (the classical way), as controller classes (like in modern frameworks), as functions, as inline code etc. In general, it's a good idea to see how others do it, go through many different options and then pick the one you like best. For example, CakePHP isn't the only framework. If you find it too heavy, there are several “micro frameworks” which you may like better. Or you can write your application from scratch, of course. Quote Link to comment Share on other sites More sharing options...
benanamen Posted December 13, 2016 Share Posted December 13, 2016 (edited) I've read your post a couple of times, and I'm still not sure what exactly you're asking for. Same here. I use router pages with includes, and using $_GET as the switch, but that seems to be getting cluttered and not very good. Are you talking about something like this? https://forums.phpfreaks.com/topic/302370-router-any-issues-comments/ Edited December 13, 2016 by benanamen Quote Link to comment Share on other sites More sharing options...
Klyx99 Posted December 13, 2016 Author Share Posted December 13, 2016 hmmm I seem to have difficulty conveying my dilemma. writing a webpage vs pascal/c++/vb etc.. is (obviously) different. without using apps like smarty, if i have a page drawn up. and I want to implement login, get customer, edit customer, add customer, all these are different methods Same here. Are you talking about something like this? https://forums.phpfreaks.com/topic/302370-router-any-issues-comments/ yes, but was unable to convey what I was looking for. as shown by people reading it multiple times LOL my small biz app is now turning into spaghetti, and for as small as it is, it should not. I'll work with this and see what I can come up with. The prob is that I have a decent css layout that looks good, so do not want to mess that up. or do redundant repetitive coding. but at the same time, do not want to incorporate a large frameworks - as that too is unnecessary for the size of my project. does that make better sense? Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted December 14, 2016 Share Posted December 14, 2016 Have you read the suggestions in #2? Nobody said you should use a large framework. There are all kinds of frameworks in all kinds of sizes. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.