Skip to main content

Questions tagged [php]

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

Filter by
Sorted by
Tagged with
-1 votes
1 answer
142 views

Best practices for creating structured data from "flat" SQL query results

Recently I've been working on a project to teach myself PHP and SQL, and as the project has gotten more complex I've been wondering what the idiomatic approaches are for creating the backend models ...
Jumhyn's user avatar
  • 162
1 vote
1 answer
82 views

How could I optimize an AJAX-based site by avoiding unnecessary/duplicate file-reads for each AJAX call?

I'm an IT guy (read: not a professional programmer) and have made an internal monitoring webtool which allows users to search for printers on our print servers. Based on the filtering criteria given, ...
mmseng's user avatar
  • 121
2 votes
1 answer
2k views

How to update HTML/JS client from PHP server without refresh intervals?

I am building a simple client-side web page that can be updated from an admin page. I am using PHP for server-side manipulation of the client targeted page. The setup feels like an overkill to me: ...
hrk's user avatar
  • 53
2 votes
1 answer
688 views

Long running REST API in PHP, async?

I have a RESTful API built with PHP. In POST request saving to DB is triggered. The problem is that now I have to support long running tasks. For example a user triggers POST request that is going to ...
stubborn's user avatar
  • 193
-1 votes
1 answer
179 views

RuntimeException or DomainException or LogicException in loader function?

Assume I have module of classes: EntityLoader loads some entity by id. EntityValidator checks preconditions, input data before saving changes. EntityUpdater saves changes. EntityLoader has method ...
тараканы_простыли's user avatar
2 votes
0 answers
64 views

How to deal with package management when having a monolith broken down in packages?

At our company we have a monolith PHP application which has been broken down into multiple (self developed) packages around the (self developed) framework package. This application isn’t a SAAS ...
Erwin Augustijn's user avatar
-7 votes
2 answers
1k views

Getting rid of dollar signs in PHP in a best way

I hate PHP dollar signs. With that in mind I tried and found a way to access variables and function parameters without using them. First, to get value of a variable I used get_defined_vars: // echo $...
Grzegorz Adam Kowalski's user avatar
1 vote
1 answer
258 views

Could this be considered a valid State GoF Pattern implementation?

For teaching purpose, I would like to create a simple implementation of State Pattern using PHP 7.4. So, I've tried to create a simple "document state machine" starting with Draft, sending to review ...
celsowm's user avatar
  • 253
-1 votes
1 answer
90 views

Ideas For Sending Messages from Contact Us Page in Website as a Notification Email to an Administrator

What is the best way to send messages from a Contact Us page in a website as a notification email to an administrator ? So far, this is what I did but I feel like this is not really the proper way. ...
Vincent's user avatar
0 votes
0 answers
586 views

DDD Value Objects and Entity Without ORM Mapping in PHP

First, as I know, Entity in DDD is almost same with Value Object except Entity has identity. Every article I have read say same thing that entity id has ORM mapping with any ORM tool. But I don’t want ...
Furkan's user avatar
  • 101
-3 votes
3 answers
144 views

What are some of the best ways to create single page websites with dynamic content?

I'm expirementing with creating a website as a IT Ticketing system. This website has a top nav and a side nav. I want the content area to change depending on the link clicked. I've managed to get the ...
Jacob Lamattina's user avatar
1 vote
1 answer
74 views

Is this form generator a valid Composite GoF?

Searching for a good PHP real world example, I've found this example of "composite" using: FormElement as Component Fieldset and Form as Containers Input as Leaf (this is my UML from the code): ...
celsowm's user avatar
  • 253
-2 votes
1 answer
404 views

Which Software Architecture am I using? XAMPP, Apache, MySQL, PHP Android

I use XAMPP to host an Apache web server and a MySQL database. Most of the data processing is done on the user's mobile phone. After a certain activity, information of the user is sent to the web ...
santa's user avatar
  • 1
1 vote
1 answer
190 views

Can Value Objects create their own value?

Let's say you have a username value object which has formatting rules e.g., class Username { private $username; public function __construct(string $username) { // thrown an ...
IMB's user avatar
  • 343
0 votes
1 answer
202 views

Memory Usage for Website

I have been working on a project and Im hoping to get a gauge on possible performance issues before I put it in any production environment. Currently on my local machine Chrome's task manager says I ...
FamousAv8er's user avatar
2 votes
2 answers
3k views

Builder Pattern: Is it acceptable to use "passing-by-reference" on Director methods?

For teaching purposes, I am trying to create a PHP implementation of a conceptual example of Builder Pattern: First of all, some products: class Product1 { private string $attribute1; ...
celsowm's user avatar
  • 253
0 votes
0 answers
78 views

Architecture Design of Command&Control application center for displays

I am facing dilemma on how to best design the following functionality. What design patterns and OOD principles should I use. For simplicity sake following are basic requirements: displays type ...
coderock's user avatar
1 vote
0 answers
76 views

Why does the PHP community always rely on file-based logging instead of a combination with in-memory logging?

This is an initial thought I'm having on logging. Clearly, am missing something about the whole picture because I don't think someone didn't think of this before. PHP runs on one request. That means ...
Daniel M's user avatar
-1 votes
1 answer
647 views

Naming my classes and class folders in PHP project

I am working on an (PHP) application where users have so called workspaces. A workspace is a folder with a specific structure and bunch of specific files - user information and some workspace metadata ...
Paflow's user avatar
  • 107
1 vote
1 answer
2k views

What is the difference between simple factory and factory method?

I am a little bit confused about simple factory and factory method. My main difficult is the abrut difference between the examples code on the internet, even on wikipedia, where have lots of them, ...
celsowm's user avatar
  • 253
3 votes
2 answers
526 views

Not confident about pre/post conditions in LSP

I have some doubts about practical ways to violate the Liskov Substitution Principle regarding pre and post conditions. I created examples in which I believe the first child respects LSP and the ...
celsowm's user avatar
  • 253
1 vote
1 answer
1k views

Why does php not allow to decrease visibility of class properties and methods in the inheriting class?

Please consider the following code: class baseclass { public $hideme; public function getit() { return $this->hideme; } public function setit($value) { $this->hideme = $value; } } ...
user106313's user avatar
0 votes
1 answer
93 views

Recursive speculative display list engine - computing text length across stack boundaries

Well, I've been hammering away on this for about a week now with no practical progress because I can't find mental fluidity with the concepts I'm trying to wrangle. I'm Officially Stumped, and would ...
i336_'s user avatar
  • 289
-1 votes
2 answers
982 views

PHP preg_replace() vs filter_var()

I have seen numerous posts on this subject but none really answered my questions. I have some user input that is inserted into my DB and displayed back to the user later. Before inserting it into the ...
FamousAv8er's user avatar
1 vote
2 answers
1k views

Loan Amortization Schedule - Precision and rounding

I have been playing around making amortization schedules in PHP. My php.ini currently has the precision set to 14. I understand going into this that there will be rounding errors however I am hoping ...
FamousAv8er's user avatar
1 vote
2 answers
2k views

If not used in a declared transaction but used in a try...catch will rollback do anything at all?

My questions are regarding the use of mysqli::rollback. If not used in a declared transaction but used in a try...catch will rollback do anything at all? (autocommit on) If it does work without a ...
FamousAv8er's user avatar
3 votes
1 answer
347 views

What domain objects might I need to represent a user and users profile in a forum web application

I’ve been trying to get a firm understanding of the MVC design pattern so that I can write my own framework for implementing the back-end of a forum web application using Slim 3. In particular, after ...
SneakyShrike's user avatar
3 votes
1 answer
583 views

Testing Queries Themselves with Test data is a Unit test or an Integration test?

In a php project that I maintain I have a database structure without migrations, hence no way to reproduce it or make on the fly a test database. And the queries used to be performed on them are ...
Dimitrios Desyllas's user avatar
-2 votes
2 answers
154 views

Securely allow access to a secure area of a website with PHP

I am making a website that requires a secure area for the website owner to easily upload new content to. Because this is a relatively simple website there is no account system. I just have a URL for ...
Jack's user avatar
  • 103
3 votes
4 answers
5k views

What is the harm in ignoring "PHP Warning: Creating default object from empty value?"

It was recommended I ask this question here as it keeps getting downvoted on Stack overflow. I am wondering What is the harm in ignoring PHP Warning: Creating default object from empty value? I don'...
pathfinder's user avatar
2 votes
1 answer
1k views

Hidden Input Fields for POST - Security

I have seen some posts on the subject of hidden input fields for use with postbut none were able to answer my question. I have a delete button tied to a user in a table. The delete button uses a ...
FamousAv8er's user avatar
1 vote
1 answer
95 views

What's the alternative to dictating possible methods to implement for a class instead of Interfaces in PHP?

I'm doing something wrong and I can't tell what, but I can concretely say that my problem is the fact that I'm looking at things wrongly and I reached a point you should never reach. I have a factory ...
Daniel Smith's user avatar
1 vote
0 answers
61 views

PHP MySQL Secure Connection - Same Server

I have some php scripts that use mysqli() to connect to MySQL which is located on the same server. I currently have the connection stored outside of my sites root and I am using include() to make the ...
FamousAv8er's user avatar
0 votes
2 answers
214 views

How can I deal with objects that might or might not implement some interfaces in PHP?

I have a collection of view objects. Each one of these objects must 100% implement the following interface: /** * Interface that each base ViewBlock object must implement. */ interface ...
Daniel Smith's user avatar
3 votes
3 answers
746 views

Altering Database Tables on the Fly, why is this a Bad Idea?

I recently saw a comment on StackOverflow that basically said it is a bad idea to alter tables on the fly. In my case I have a json file that is storing some information about some "products". One of ...
FamousAv8er's user avatar
0 votes
0 answers
464 views

Implement multiple file upload with Dropzone.js , Lambda and S3

This is more a general question about this project I have on. We need to implement some UI for our costumers to upload multiple files (2000+) every month, so we can send them by email to another ...
jspasiuk's user avatar
2 votes
2 answers
1k views

PHP - Enforce classes to have method with parameter/return value of `self`

SCENARIO I am implementing "command pattern"-like classes. Since they are so similar to each other in so many sense (e.g. functionally, their relation in domain problem, etc.), it is ...
mghazian's user avatar
-3 votes
1 answer
215 views

What kind of factory method abstract singleton design pattern is this?

I made a code that seems to mix Singleton design pattern, and Fatory method. But my factory method is in an abstract class inherited by my Singleton ... what the hell have I created ? Does it have a ...
Motiss's user avatar
  • 1
2 votes
2 answers
130 views

Elegant way to relate two php scripts

I have been writing some code in PHP for a bit of time, but I am still pretty new on it. I have a script with all functions I need for my webapp. The script looks like this? function foo(bar){...} ...
Marco Tulio Souza's user avatar
2 votes
1 answer
685 views

What is the easiest and most flexible to scale method for handling recurring tasks that don't have an end date and will dynamically change?

Problem: I'm writing a service in Laravel 6.2 that will send out a push notification to different users at specified times down to the minute. Users select how many times a month, week, or day and at ...
SaundersB's user avatar
  • 147
2 votes
3 answers
627 views

PHP : authentication with a temporary link

in my system users register with their email address and receive a temporary link to log in. hostname/login/OYkwIJt6be1V5kMg10G The token must be generated from the email adress of user and valid ...
Mary's user avatar
  • 129
2 votes
4 answers
251 views

Is it a bad practice to query remote resources inside validation?

Watching this talk about Symfony Forms and validation, at 23:06, I got stuck with a doubt I couldn't find a satisfying answer to: Is it a bad practice to execute a query (or a web request, or a side ...
Kamafeather's user avatar
1 vote
2 answers
55 views

Create object(s) to cater for two data sets that are the same entity but one has an additional element

When I call an API endpoint I have a class to create an object with the response. The object directly maps the endpoint elements so I have all values, with properties, getters, and setters. In my ...
James's user avatar
  • 243
5 votes
2 answers
3k views

Clean Architecture - How to pass request data towards inner, domain level Use Cases?

Use Case Interactor: We can see it in this picture how does a request cross the layers until it reaches the Use Case Interactor. How does the controller pass the request towards the Use Case ...
NCode's user avatar
  • 65
1 vote
2 answers
850 views

Event Sourcing - Can a read model/projection be used in business rules within an aggregate?

I know that the general concept behind event sourcing is that the state of the application should be able to be replayed from the event stream. Sometimes, however, we need to get information for ...
Adam Lambert's user avatar
2 votes
2 answers
108 views

Server-side script to handle many near-simultaneous incoming XMLHttpRequests

I am building my own analytics platform, which I want to work like this... A JS script in each of my webpages collects data about users' clicking behaviours and sends that data to a PHP (or other ...
Steve_P's user avatar
  • 31
1 vote
1 answer
44 views

Determine array of objects collective identity and be able to inspect it

I have an array of objects and I'm trying to see, through each request, whether or not a new member appeared in my collection. The way I currently do it is, I require each member of the collection to ...
coolpasta's user avatar
  • 641
-1 votes
1 answer
134 views

How to test and what kinds of test to write for Request Handlers that use Repository layer?

Consider class below: class FillTestBySerialHandler { /** * * @var FillTestBySerialRepository */ private $fillTestBySerialRepository; function __construct(...
Dennis's user avatar
  • 8,247
0 votes
0 answers
455 views

Parsing custom if statement input in PHP

I'm working on a feature where users can get data based on the if statement they write. The if statement looks something like the excel's conditionals. Basic syntax: IF ( lhs == rhs, ifTrue, ifFalse)...
Shahlin Ibrahim's user avatar
2 votes
0 answers
42 views

Web Service returning serialized helper objects

I had the idea to have a route in my REST API that returns serialized (PHP) helper objects. The client code then can use those objects to format some complex JSON structures for the next request. When ...
Benni's user avatar
  • 121

1 2
3
4 5
41