Comments (6)
No problem! I've looked at #22, and personally, getting a routing library in place is the first step. The second step would be adding a container. Adding a container would allow you to remove all your static methods/classes, and set your parameters dynamically. Doing ALL of that would allow you to remove your globals - but it would be a pretty big undertaking. I'm not sure you could take a shortcut in doing #22, but it wouldn't be very pretty or long-lasting.
I'd really like to help you out, but in the list of ways to modernize this app, #22 might be towards the bottom of the list. Towards the top would be finish setting up a routing library and forwarding all routes/urls to index.php. Your second step would probably be creating dedicated classes for certain routes/actions, like 'games' and 'profile', etc. Cut out all the if/else logic in your code based on what route a user is taking or which form is submitted - that can get really confusing, and is hard to maintain.
Let me know if you're interested in any of this - I'd be happy to set up tickets for these things. I would like to help with #22, and I've tried in my own development, but it's going to be pretty near-impossible without these other updates.
from phparcade.
You would usually use an ID in a URL like this to explicitly allow for the possibility of the non-ID part of the URL changing. For example, if you rename a game from The Weakest Link Beta
to The Weakest Link
you do not want previously used game/1613/The-Weakest-Link-Beta.html
links to produce a 404.
The solution to ensuring there is only one single path to a game is to generate and store a canonical path (e.g: game/1613/The-Weakest-Link-Beta.html
) and 301 redirect any request from a non-canonical path to the canonical path. This means that if the canonical path changes (e.g: game/1613/The-Weakest-Link-Beta.html
becomes game/1613/The-Weakest-Link.html
) all existing links will continue to link to the intended page (through a single redirect).
from phparcade.
I can come up with a routing solution for you. Would you prefer @citricsquid's approach?
from phparcade.
That would be an amazing help. That approach sounds fine.
from phparcade.
Thanks for the contribution. This has an interesting (positive) side effect where it seems that it "bypasses" the score submit page, but the score still submits. Maybe this just made it ultra fast? In either case, scoring still works, but anything that reduces wait time is a good thing.
I'll have to look into phroute more, but I think I'd like to do something similar with the profile/ and page/ pages, ideally to eliminate the massive array that it uses now (which is a holdover from when the app was first written in PHP3). Something we can look at more in #22 but if you don't mind, I may reach out to you around that change. Unless you want to take that one on too.
Thanks again for the help here. In my mind, this is a big step in making the code more flexible for the future.
from phparcade.
Yep, I fully agree with your assessment. I haven't worked too much with routing libraries (other than just plugging them in with something like CI or Laravel), so this is a bit new to me. It's been on my list for a long time -- long before I got permission to make this open source, so I'm not in any rush. Though repo corruption caused me to lose most of my commit history and I can't really prove it, it's come a long way. For example, at the start of this year, there were no classes anywhere and nearly all functions in the entire codebase required globals (I removed/refactored most of them).
The code base has a long way to go to get it to be where I'd like it, but the ride to get there has been a great learning experience.
My other life commitments only allows me to do work on the project in spurts, so I'll definitely take any help offered (whether it's just idea generation, one line, or 10,000 lines) and truly appreciate your contributions thus far.
from phparcade.
Related Issues (15)
- Build GUI installer HOT 2
- Please provide more clear install details HOT 5
- Fix create_database.sql scripts #1 HOT 4
- Linux-Specific Function
- Add SameSite Cookie attribute
- Eliminate the loadLinks() global and array HOT 1
- Build proper URL routing HOT 2
- Update Google Tag Manager code HOT 1
- Integrate Mixpanel HOT 1
- Modify plugin admin pages to not use foreach loop HOT 2
- Eliminate $config global HOT 1
- Add location parameter to stored procedure HOT 1
- Change admin toggles to be AJAX
- Implement Chrome browser notifications when high score is beat HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phparcade.