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 ...
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 ...
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 ...
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 ...
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
<...
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 ...
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
...
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 ...
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 ...
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 ...
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:
...
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 ...
1
vote
Paginated method to get all items
PDO
Like I said before, moving to PDO will reduce the following code block
...
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.
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
slim × 17php × 15
mvc × 5
object-oriented × 4
api × 3
mysql × 2
ruby-on-rails × 2
pdo × 2
mysqli × 2
rest × 2
beginner × 1
jquery × 1
html × 1
ruby × 1
sql × 1
security × 1
validation × 1
authentication × 1
dependency-injection × 1
laravel × 1
.htaccess × 1
php7 × 1
symfony4 × 1