Skip to main content
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,608
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

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
3 votes
Accepted

Global site settings middleware for Slim Framework 3

A couple of general comments: Please follow the PSR coding standards whenever possible Add type-hints for all arguments, especially constructor arguments. You're clearly expecting ...
Elias Van Ootegem's user avatar
2 votes

Slim 3 dynamic middleware code optimisation

I'm not 100% sure what you're trying to achieve as I tend to prefer explicit over magic configuration, but here's a few thoughts. Middleware in Slim and many other frameworks uses the function ...
Rob Allen's user avatar
  • 121
2 votes
Accepted

Form validation for user account creation

Don't nest your conditions like this. Validate the input up front and fail out if need be. For example that might look like this: ...
Mike Brant's user avatar
  • 9,608
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,096
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,608
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
1 vote

Form validation for user account creation

Since at most one of the messages will be selected, you should invert the conditions to make it linear rather than nested. This has the benefit of putting each error message right next to its ...
200_success's user avatar
1 vote

Initial stages of MVP, is the bootstrap file efficient coding

You can add another folder named libraries inside of app. Follow a particular case convention. Like don't have ...
tovishalck's user avatar

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