Questions tagged [php]
Questions about PHP, a widely-used general-purpose scripting language that is especially suited for Web development.
2,057 questions
1vote
1answer
106views
Best practice for integrating UI and dynamic user-specific content using a Flask app
I am building a website that uses a recommendation system. Users submit a form which is sent to the backend for the recommendation logic calculation; the recommendation response is sent back to the ...
2votes
1answer
148views
Is widening parameter types in a PHP interface implementation a good practice?
I have an interface defined as follows: interface MyInterface { public function setMyMethod(int $a); public function getMyMethod(): int; } And I have a class that widens the parameter type: ...
-2votes
1answer
83views
PHP secure storage for sensitive document uploads [closed]
I need help deciding how to securely store sensitive docs uploaded via a PHP script. I realize I'm not personally qualified for this task (if I was I wouldn't be asking this question) but need to know ...
0votes
1answer
257views
How to share transaction across multiple repositories in DDD?
We are trying the Domain Driven Development (DDD) while working on a project. We've got a Product aggregate. We've got a ProductRepository to load/save Products. We've also got a Timeline aggregate, ...
0votes
1answer
227views
DTO Interfaces naming convention in PHP
It might be that my question would sound a bit stupid but I would like to find the best way for naming my DTO interfaces. In my PHP application I have following DTO types: Simple (which contains a ...
4votes
2answers
273views
Interface + Trait vs Abstract Class
While developing my application I faced an interesting situation: I have multiple DTO's which are almost identical in terms of methods, only properties are different. For example I have AccountDTO ...
1vote
1answer
168views
DTOs and Single-responsibility principle
I'm developing a PHP application and trying to understand DTOs in context of single-responsibility principle. Being more specific, is it a bad practice having helper methods like toArray(), getValue(),...
-3votes
1answer
111views
Mock an API for development purpose (no testing)
If I want to implement a connection from my software to an API, which is documented but not accessible yet, what is a common way to imitate the API until it is available? My first idea was to mock the ...
0votes
1answer
186views
Our php codes base has 6 different ways to do INSERT … ON DUPLICATE KEY UPDATE, how do I fix it?
Our php codes base has 6 different ways to do INSERT … ON DUPLICATE KEY UPDATE. It happened over years because the php framework is evolving and my team members come and go, although I won't say we ...
2votes
1answer
173views
How is $this provided in PHP?
I got a fundamental question about the $this keyword in PHP and how it is defined. Pracitcally, I know what it is and what it does. But I am interested in how it is provided / implemented? For example,...
2votes
2answers
381views
Unit testing for non-stateless units - how?
Firstly let me say I have never written a unit test in my life. I am trying to get the hang of PHPUnit, and so far it's working pretty well for me so far as "stateless" functions (that ...
-1votes
1answer
219views
Best practices for organising PHP files?
I am currently writing a PHP / JavaScript application library, which I intend to use in the future for several other applications. The library includes functionality for handling a database, creating ...
0votes
2answers
304views
Should I split backend into legacy and modern app to make the rewrite feasible?
My vanilla PHP backend app needs to be rewritten due to very poor design and lot of unstructured code. The legacy app is very large and the team small, so doing full rewrite in limited time is quite ...
1vote
3answers
383views
frontend server obtain data from backend server, or frontend server return page with javascript that obtain data from backend server?
I'm currently learning how to separate frontend server and backend server. However, i'm not sure which approach should i take between the two Frontend server obtain data from backend server and ...
2votes
1answer
207views
What is the proper pattern for a singleton SETTINGS class load using composer?
I have a class file Settings.php that loads an ini file and assigns the content to a constant for global access and reducing clutter. The class file contains the logic for loading the settings and ...