r/PHPhelp • u/larsnielsen2 • Dec 21 '24
Name structures for CMS
I am developing a CMS in PHP in my spare time for fun :) I have been working many years in Drupal and my mind is a little locked on entities and the path structure in Drupal 8+
Can you suggest a good alternative to paths like this:
user/234
user/234/edit
user/register
page/23
page/23/edit
Kind regards :)
4
Upvotes
8
u/Wooden-Pen8606 Dec 21 '24
That's a pretty common route structure. Nothing wrong with it. Very functional. One alternative is to use slugs in place of ID numbers.
You could go old school PHP and do something like /post.php?mode=edit&id=23. (joking)
4
u/jalx98 Dec 22 '24
IMO I would modify the user/register and leave it as user/ ; using a POST method should give you tje functionality to create a new one
3
u/[deleted] Dec 22 '24
Look into RESTful routing
2
u/Square-Ad1434 Dec 22 '24
you can also do things like /account/dashboard, register, login, forgot_password etc its your choice just do something that makes sense really.
1
u/p1ctus_ Dec 21 '24
That's pretty common and what I would expect as dev hopping into this project.
I prefer the plural version but that's only my favor.
Eg: users/<id> users/<id>/edit
1
u/oxidmod Dec 23 '24
Replace action (/edit, /register, etc) with HTTP method and you good
1
u/yourteam Dec 25 '24
If you wanna do something fancy you can have an uuid as a key to load the user (not primary key of course)