4
votes
Angular2 Route Interceptor
I found this post because I needed something that did what you implemented. I tried to use the code and ran into some nasty routing bugs whereby Angular was experiencing internal errors. The cause is ...
4
votes
A very basic web framework inspired by Flask
That's a nice mini-flask exercise.
ROUTES = None
Deferring the assignment to later, and initializing to Routes(), would seem ...
4
votes
Accepted
URL router for production
I see some things that may help you improve your program.
Separate interface from implementation
It makes the code somewhat longer for a code review, but it's often very useful to separate the ...
4
votes
Accepted
PHP Router For MVC with strict routing requirements
Your router is doing too much.
Router should do one thing and one thing only. It should map request uri to a specific request handler (controller action).
You may get a better architecture if you ...
3
votes
Accepted
PHP code for blacklisting and rewriting/redirecting URLs
I think it looks good, a little verbose. Could be simplified to this
...
3
votes
Accepted
Simple MVC built in PHP
As Your Common Sense noted in the comments, leveraging auto loading classes in PHP can help clean up your includes for the controller files (and model classes too).
Some additional improvements:
...
3
votes
Assigning several variables from request URL using regexes
I'm not really comparing before and after. Without seeing the data that comes in that's a bit hard. Instead I'll focus on the new code.
In general, a lot of your variables could benefit from clearer ...
3
votes
Accepted
URL Routing Application
You could do the following. (I assume you already have a resourceful route for your documents right?)
...
3
votes
Accepted
Two java classes with different annotation values only
You can parameterize the @path annotation with regular expressions to specify one class/method that accepts multiple paths
...
3
votes
3
votes
PHP Router For MVC with strict routing requirements
Code styling (refer to PSR-12 guidelines)
Mind your class bracing and spacing: https://www.php-fig.org/psr/psr-12/#41-extends-and-implements
Mind your method bracing and spacing: https://www.php-fig....
2
votes
Protect against XSS with .htaccess file
Neither you .htaccess file or your .php file would be Vulnerable to Xss Attacks as they are both server side scripts which would never be Shown to a user & therefore would not be easily ...
2
votes
PHP routing system
I apologize that nobody has reviewed this code in six years since it was posted. Perhaps you have learned a few things since then but hopefully the review below will still be helpful.
Array syntax
I ...
2
votes
Accepted
Simple Router class
If we define SOLID as it is stated on Wikipedia:
Single-responsibility principle
Open–closed principle
Liskov substitution principle
Interface segregation principle
Dependency inversion principle
...
2
votes
PHP MVC framework
You are on the right path. Your implementation is MVC.
The only thing your design is lacking is inheritance.
...
2
votes
Accepted
PHP MVC framework
my controller uses conditional statement based on parameters supplied after the controller and action part of the url to call different views, and I've read somewhere that having controller decide ...
2
votes
PHP OOP API Class
Overview
I think the interface and implementing classes looks fine. If there were common methods that both classes implementing the interface would use, then an abstract class might be a good route ...
2
votes
Accepted
Express.js routes management for large web application
absolutely, you should compose your express application in terms of a hierarchy of routers
instancing all those routers should be negligible in terms of your application's performance
this is the only ...
2
votes
Angular2 Route Interceptor
A proposal with Subscription in returns to be able to unsubscribe all actions.
...
2
votes
Simple routing system
Firstly, I would consider switching off error suppression, and add in Exception handling. You could in this example add in a condition to check if each file exists before including it, for instance:
<...
2
votes
create static page with vuejs
This may be an incorrect assumption, but it seems like with your proposed approach, you would need to either keep the HTML for each page within the HTML for the main page in the onclick attributes for ...
2
votes
Accepted
Load other files (from outside public_html) under index.php
Preface
I wouldn't use the query string of the URL at all.
The problem with using GET, is that GET is meant for other things such as bookmarkable search link etc. As you add more ...
2
votes
Load other files (from outside public_html) under index.php
You can simplify your regex pattern and you might like to combine your validation with the preparation step. The following pattern is just like yours except it allows a single trailing slash and ...
2
votes
http router written in Golang
You write:
func (r *Route) Match(req *http.Request) bool {
regex := regexp.MustCompile(`{([^}]*)}`)
// ...
}
Therefore, we would expect your performance ...
2
votes
Router and solid principle
Router should not accept request object in constructor. You will need a new router for each request.
I know PHP spawns a new process for each request so it gets created for each request anyway. But in ...
2
votes
Router and solid principle
As a general best practice rule, I would advise that any time you are going to be feeding a variable into a regex pattern string AND that variable isn't 100% guaranteed to be free of characters with ...
2
votes
NextJS with a root level catchall route for all URLs dynamic middleware that splits into components
Feedback
For a first attempt at a middleware it looks decent. It is a bit on the long side and hopefully the suggestions below can help with that. It is great that strict type comparisons are used. ...
2
votes
Index.php automatic router for custom MVC
Half given answer, use an existing framework - everyone regrets building their own framework (including me)
session_start() is bad - API calls wont have a session.
<...
1
vote
Improving PHP MVC code for personal website
If you want to learn best practices in MVC, I would suggest you to have Slim framework. If you don't want to use an existing framework and develop your own, still, I would recommend to install it on ...
1
vote
Accepted
Simple Go REST API that returns dummy messages
There's not so much code that it would be hard to read, looks clean enough to me.
Regarding scalable ... in what way? The switch in Handler will be the limiting ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
url-routing × 128php × 72
mvc × 43
object-oriented × 21
javascript × 15
c# × 10
ruby × 8
node.js × 7
security × 7
ruby-on-rails × 7
.htaccess × 7
react.js × 6
beginner × 5
regex × 5
http × 5
jsx × 5
controller × 5
performance × 4
design-patterns × 4
go × 4
express.js × 4
comparative-review × 3
ecmascript-6 × 3
asp.net × 3
laravel × 3