Skip to main content

Questions tagged [php]

Questions about PHP, a widely-used general-purpose scripting language that is especially suited for Web development.

-2 votes
0 answers
40 views

React js POST method to two or more tables [closed]

I'm a newbie to react and PHP and have been trying to learn it by a random car project with crud operations. Right now i'm only using CRUD operations on coches (cars) table and it works just fine. ...
Annie's user avatar
  • 9
0 votes
1 answer
164 views

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 ...
Qiulang 邱朗's user avatar
2 votes
1 answer
162 views

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,...
tweekz's user avatar
  • 237
2 votes
2 answers
336 views

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 ...
user avatar
-1 votes
1 answer
98 views

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 ...
user avatar
0 votes
2 answers
268 views

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 ...
user14967413's user avatar
0 votes
0 answers
23 views

An IoT client and MVC-based server. Data model with different fields per type?

The problem Let's assume such scenario: List of IoT devices (one model?) Each list item has (among other fields) a type field Depending on the value in the type field, device may report different ...
trejder's user avatar
  • 2,406
1 vote
3 answers
240 views

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 ...
LLL's user avatar
  • 111
2 votes
1 answer
175 views

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 ...
theking2's user avatar
  • 140
3 votes
2 answers
380 views

Is it okay to use Dependency injection only because of unit testing?

I have a class that has dependencies that I know are not going to change. class ConversationFinder { public function __construct( protected Conversation $conversationDbFinder = new ...
Ghassan Barghouti's user avatar
1 vote
2 answers
230 views

Best way to protect action links from CSRF

An application has a multifactor login. The user logs in with its e-mail and password, and then the following screen asks for a one time password received via e-mail or generated by a mobile app. In ...
user2190492's user avatar
0 votes
0 answers
55 views

How to group together common allowed descendants of a vertex in a tree data data structure?

I created an abstract class to represent a vertex in a tree structure. Later, a requirement was introduced where certain types of vertices are not allowed as descendants of certain other vertices. So ...
Cave Johnson's user avatar
1 vote
1 answer
435 views

Languages with PHP-like traits?

PHP have what it calls "traits" which despite the name is not like traits in Rust, Scala or other languages. In many other languages with support for traits, a trait create a is-a relation. ...
Fred's user avatar
  • 489
2 votes
3 answers
239 views

Organize and maintain a lot of cron jobs

I am working on a fairly large project written in PHP (Yii2) in which we are increasingly using cron for background tasks, such as generating caches, reports, etc. We have started to move the hourly ...
MKMarek's user avatar
  • 29
1 vote
1 answer
217 views

Why does PHP have int and float data types?

I have realized that PHP can treat string variables as numbers (as long as int or float values are stored in the string variables), for example: <?php // Declaring two int numbers and one float ...
user21403677's user avatar

15 30 50 per page
1
2 3 4 5
137