Skip to main content
4 votes
Accepted

Using PHP goto Labels for code folding

The main issue I have with your approach is that it is non-standard and purely for the way that you work. Others looking at your code may be a bit confused as to what you are doing and why. In your ...
Nigel Ren's user avatar
  • 368
4 votes

Restful resource with pagination and additional mapping

I am guessing that there is some bootstrapping script which is instantiating your slim application an including this controller, so my first thought is, if that is the case, shouldn't fundamental ...
Mike Brant's user avatar
  • 9,638
4 votes

To-do app API made with Slim 3

In short, no. Actually doesn't seem to be structured in any way :D If your API will be just that, you can even give up on slim and have a plain index.php with url rewrite so you can achieve the best ...
NemoXP's user avatar
  • 141
3 votes
Accepted

To-do app API made with Slim 3

Is the application well-structured or should I move the logic into controllers? I agree with NemoXP that the current format is not well-structured. A file with 112 lines of code isn't horrible in ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
3 votes
Accepted

Is this an good OOP Design in MVC PHP for getting User Details?

There is not much OOP to review it. Actually that's just two functions, so one can review only the code, not the object structure. All in all there is a lot of repetitive or outright useless code <...
Your Common Sense's user avatar
3 votes

Using PHP goto Labels for code folding

Most has already been said by Nigel Ren. However, your questions about performance issues and overhead remain unanswered. Using a label comes with very little overhead, so you really don't need to ...
KIKO Software's user avatar
2 votes

Paginated method to get all items

SQL Injection You are vulnerable to SQL injection via pageSize. You need to use prepared statements for all values, not just some of them. Naming ...
tim's user avatar
  • 25.1k
2 votes

PHP RESTful API for a student repository

The StudentRepository is all about database, and shouldn't know about $request and $response objects, that is the job of the controller. What if you were fetching data to put in an excel file, then ...
bumperbox's user avatar
  • 2,106
2 votes
Accepted

PHP - How can I refactor this store function (which handles different database operation for user types) in order to reduce duplication?

I think it's a very good case to employ OOP, namely polymorphism and inheritance. First, we've got to create a dedicated class to handle the user preferences. A common ancestor to hold all the ...
Your Common Sense's user avatar
1 vote

PHP - How can I refactor this store function (which handles different database operation for user types) in order to reduce duplication?

I'll start by listing some notes on the code itself and then I'll suggest a new architecture that I think will help improve the 'maintainability' of the code. As @YourCommonSense said, the ...
Mahmoud Farouq's user avatar
1 vote
Accepted

Is there any better / improved / optimise way to approach these input checker?

There's A LOT or repeated code. Start by DRYing your code, for example: All this lines are too similar: ...
arieljuod's user avatar
  • 146
1 vote

MVC Auth Structure and Dependency Injection with PHP-DI 5 and Slim 3

public function doLogin(Request $request, Response $response, Twig $view, Auth $auth, User $user) Why do you need to have both ...
Mike Brant's user avatar
  • 9,638
1 vote

Paginated method to get all items

PDO Like I said before, moving to PDO will reduce the following code block ...
Your Common Sense's user avatar
1 vote

Secure login and authentication in PHP

This isn't a matter of security, but mashing things onto a single line else { return $user; } is considered poor form in most style guidelines. ...
Xiong Chiamiov's user avatar

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