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
0
votes
1answer
34 views

PHP: What code should be removed to its own helper class and where should such classes be located in the filesystem?

The following is an example requesting an explanation for one specific file in one specific filesystem, not helper classes generally. I have configured a LEPP stack on a CentOS server. The server ...
-3
votes
2answers
26 views

Interconnected technique for web, mobile and desktop

I am planning to do the university project with the Desktop application + web application + mobile application, I have planned to use languages for these 3 as below: Desktop application: Java SE Web ...
-4
votes
0answers
23 views

Better option for this nested if condition [duplicate]

I am working on one module where three Condition is available and each option contains three options. Enable : Yes/No Who can see : All / Login /Guest Which Product : All / InStock / ...
42
votes
8answers
7k views

Is it common practice to validate responses from 3rd party APIs?

I'm working on a PHP web application that depends on a few 3rd-party services. These services are well documented and provided by fairly large organisations. I feel paranoid when working with ...
-2
votes
0answers
25 views

How to increase number of http queries ran by php queue workers?

I'm building uptime monitoring service, which consists of many nodes which are sending http requests to different hosts. As a framework use Laravel and its queues. Like, at first I dispatch jobs into ...
-5
votes
0answers
16 views

Live video from android app and send to php website for viewers to see

So basically i want to build a online study portal. There will a android app for tutors. Students (id,password will be given to login) will go to a webpage in which they will view the live video ...
-3
votes
1answer
39 views

Proper way to organize Small Functions in PHP

I have a bunch of small utility PHP functions that I made to solve different scripting problems. Functions like UUID() and trackUserActivity() etc. There are tons of these functions and increasing ...
-1
votes
1answer
41 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 ...
1
vote
1answer
38 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, ...
1
vote
1answer
60 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: ...
1
vote
1answer
55 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 ...
0
votes
0answers
33 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 ...
2
votes
0answers
35 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 ...
-7
votes
1answer
82 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 $...
0
votes
1answer
68 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 ...
-1
votes
1answer
44 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. ...
0
votes
0answers
44 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 ...
-3
votes
3answers
124 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 ...
1
vote
1answer
49 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): ...
-2
votes
1answer
87 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 ...
1
vote
1answer
148 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 ...
0
votes
1answer
96 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 ...
0
votes
0answers
31 views

Composer Update — Need to Push?

I have a private PHP library that is working well for the most part. Let's call it "private library". I can move into the "private library" and edit, git add, git commit and git push -- all as you ...
2
votes
2answers
148 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; ...
0
votes
0answers
63 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 ...
1
vote
0answers
72 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 ...
-1
votes
1answer
46 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 ...
1
vote
1answer
164 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, ...
2
votes
1answer
78 views

No confident about pre/post conditions on LSP

I have some doubts about the practical way of violate or to not the pre and post conditions based on Liskov Substitution Principle. In the beginning, I have create the examples where first child ...
0
votes
1answer
90 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; } } ...
0
votes
1answer
67 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 ...
0
votes
2answers
98 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 ...
1
vote
1answer
139 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 ...
1
vote
2answers
201 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 ...
3
votes
1answer
166 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 ...
2
votes
1answer
81 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 ...
-2
votes
2answers
70 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 ...
1
vote
3answers
147 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'...
2
votes
1answer
104 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 ...
1
vote
1answer
53 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 ...
1
vote
0answers
38 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 ...
1
vote
1answer
89 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 ...
3
votes
3answers
298 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 ...
0
votes
0answers
81 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 ...
1
vote
2answers
139 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 desirable to ...
-3
votes
1answer
118 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 ...
2
votes
2answers
101 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){...} ...
1
vote
1answer
162 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 ...
0
votes
0answers
27 views

Import many data using dto between multiple modules

I am working on a symfony application where i have complex user data coming through an external json feed. This data is usually a 100MB json feed from which i have to read user data (with all its more ...
2
votes
3answers
87 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 ...

1
2 3 4 5
40