Skip to main content
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 ...
MgSam's user avatar
  • 141
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 ...
J_H's user avatar
  • 42.1k
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 ...
Edward's user avatar
  • 67.2k
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 ...
slepic's user avatar
  • 5,657
3 votes
Accepted

PHP code for blacklisting and rewriting/redirecting URLs

I think it looks good, a little verbose. Could be simplified to this ...
Rager's user avatar
  • 251
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: ...
Greg Burghardt's user avatar
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 ...
simbabque's user avatar
  • 1,033
3 votes
Accepted

URL Routing Application

You could do the following. (I assume you already have a resourceful route for your documents right?) ...
siegy22's user avatar
  • 146
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 ...
Sharon Ben Asher's user avatar
3 votes

PHP Routing with MVC Structure

Connecting to a database ...
mdfst13's user avatar
  • 22.4k
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....
mickmackusa's user avatar
  • 8,802
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 ...
Ryan Stone's user avatar
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 ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
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 ...
Potherca's user avatar
  • 530
2 votes

PHP MVC framework

You are on the right path. Your implementation is MVC. The only thing your design is lacking is inheritance. ...
MontrealDevOne's user avatar
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 ...
tim's user avatar
  • 25.3k
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 ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
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 ...
ChaseMoskal's user avatar
2 votes

Angular2 Route Interceptor

A proposal with Subscription in returns to be able to unsubscribe all actions. ...
Zéfling's user avatar
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: <...
Shaun Bebbers's user avatar
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 ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
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 ...
ArtisticPhoenix's user avatar
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 ...
mickmackusa's user avatar
  • 8,802
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 ...
peterSO's user avatar
  • 3,591
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 ...
slepic's user avatar
  • 5,657
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 ...
mickmackusa's user avatar
  • 8,802
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. ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
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. <...
Dan's user avatar
  • 530
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 ...
Shaunak Sontakke's user avatar
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 ...
ferada's user avatar
  • 11.4k

Only top scored, non community-wiki answers of a minimum length are eligible