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
0answers
13 views

Filter Gallery Images based on dropdown selection values

I currently making a "visual plan builder" with php-mysql, ajax and jquery Using multiple layers (z-index) I generate a visual plan with the following dropdown list values: Base Product - ...
1
vote
1answer
134 views

Is this correct adherence to Liskov Substitution Principle?

I used to have a base object with subtypes behaving in all but the same way -- the difference being in their render methods. This base class defined a default render method, overridden by Some ...
-2
votes
1answer
49 views

Authentication solution for custom PHP-based API

Here is description of my app I'm working on. On the client-side (index.html) a user can interact with a data. When he needs to call a server operation for example reading or writing a file on the ...
3
votes
3answers
263 views

Caching model objects to avoid multiple SQL commits

In decomposing a monolithic web application into smaller services and by following the Strangler Fig pattern, I'm in the middle of a problem for which I can't find a practical solution. There is a web ...
0
votes
0answers
22 views

Design pattern for duplicating lines of code in control structures [duplicate]

on my website I have a multi-page form where user can pass some data on each view, but user can also save a draft on specific step(in my example 1-4). My service has a dispatch method. Based on step(1-...
1
vote
4answers
181 views

Is having 3 return types for a function, in order to facilitate error handling a bad idea?

I have a function which returns either true/false, each return plays nicely with the function name: isOnline, however, there are cases in which I want to throw an error inside of it. Maybe the status ...
-1
votes
1answer
56 views

How to write package for two frameworks

I'm developing a package for Laravel & Lumen in the same code base, but I encountered some problems. Well, in the beginning, I thought it could have the same code and work for both frameworks, ...
2
votes
0answers
66 views

I'm trying to write something that will fill out an Australia Post Declaration Form [closed]

I've got basic proficiency in PHP, JavaScript, html, and SQL. I also use Postman little a bit. I hope a solution to my problem can be found within those skills, but I'm willing to learn a new language ...
0
votes
0answers
37 views

How to name multiple entities returned from a Query Handler?

I've got the following flow: HTTP API is exposing data from 2 database tables that are combined into one JSON structure. We're implementing this using CQRS - splitting the reads from multiple tables ...
-4
votes
1answer
55 views

How could I redefine a new type for subclass

I'm trying to represent some entity. LineProduct A line holding a quantity of product and a Product entity LineProductBlank A line holding a quantity of product and a ProductBlank entity Product ...
-8
votes
1answer
68 views

Are the stone-dead PHP mailing lists really how PHP developers and the PHP community communicate? [closed]

I've been looking at this for a long time: https://news-web.php.net/ Almost every single mailing list has the last messages sent to them in the year 2000-2003. That's 17-20 years ago! It would be an ...
53
votes
11answers
11k views

Is there a general solution to the problem of “sudden unexpected bursts of errors” in software?

Let me explain what I mean. I have made a complex, highly polished over years PHP framework/library for my own use. I very aggressively log the smallest notice and immediately deal with it as soon as ...
2
votes
0answers
160 views

How to handle a bunch of nested ValueObjects?

I'm writing a PHP web application (or actually a Symfony module). One part of it is a nested structure of ValueObjects (meaning: they are immutable and have to be validated on the creating). Such an ...
0
votes
2answers
141 views

For a very long lived PHP web application project, is custom (self made) framework better than (open source) popular frameworks?

For a project that's going to live/used/maintained by the developer for a very long time (ex: 20-50 year); Is custom (self made) framework better than (open source) popular frameworks? Basically my ...
-6
votes
1answer
75 views

What is the best option between buying, building from scratch or implementing an open source ERP? [closed]

I was required to do a medium ERP with the inventory, Bill of Materials, and production modules. However, I do not know how long it would take me. I am calculating three months for the analysis and ...
0
votes
1answer
98 views

Design leading to break contravariance. How to avoid it?

I have a Converter which use a Resolver to determine which Factory to use when converting a Resource to a Entity. To do so, I need to be sure that the Factory has a createFromResource method. The ...
-2
votes
1answer
51 views

Why does DateInterval lack weeks, quarters/seasons, as well as decimal/float versions of each property?

This has puzzled and frustrated me for years: https://www.php.net/manual/en/class.dateinterval.php y Number of years. m Number of months. d Number of days. h Number of hours. i ...
-2
votes
1answer
144 views

SOLID way to handle user input error (I18N & error context problematic)

Disclaimer : I come on this topic after it has been recommended to me on my previous closed SO topic (see closed one : https://stackoverflow.com/questions/64338968/how-to-effectively-manage-a-large-...
0
votes
1answer
118 views

DDD Aggregate in PHP — how to retrieve the root?

Status quo I created an aggregate, let's call it Foo. It has two entities within itself, let's call them Foo & Bar. You can mutate things by calling the aggregate's public methods. E.g. $foo->...
0
votes
2answers
82 views

How to effectively manage a large number of exceptions (I18N problematic) [duplicate]

I'm trying to found the best way to manage Exception for all over my application. Actually, I've come with two solutions : Solution 1 One Exception to govern them all. namespace App\Utils\Exception; ...
-1
votes
1answer
67 views

Setter dependency injection or locator pattern

Let's say that I have the following class. class Application { protected $dependency; public function setDependency($type) { $this->dependency = ServiceLocator->...
-4
votes
1answer
76 views

Create an e-commerce that integrates other store

I would like to create an e-commerce website that integrate other e-commerce. I can retrieve their products using APIs or feeds. The problem is that all these information are different from shop to ...
-2
votes
1answer
65 views

Does DigitalOcean offer enough resources to run a scalable MySQL cluster?

I have a kubernetes from DigitalOcean that has 2 worker nodes and 1 load balancer. Now I want to create a MySQL managed database cluster for the app that will run on that kubernetes. Question is: does ...
0
votes
4answers
228 views

An action in my controller has too much responsibility

(Disclaimer : I'm asking this question here because as it is opinion-based, it have been closed from https://stackoverflow.com/questions/64050308/an-action-in-my-controller-has-too-much-responsibility)...
-2
votes
1answer
127 views

First time teamwork (PHP): version control and continuous integration?

A colleague and I are going to be working together on a single project for the first time. This raises a few technical questions for me. Like how. I think a version control system is a must now, if it ...
0
votes
2answers
103 views

How can you avoid doing hundreds/thousands of queries when utilizing classes in PHP?

I have been dipping my toes into object orientated PHP programming and I'm finding it useful but I can't help but feel I'm missing something in regards to how to utilize it. Normally my classes and ...
-1
votes
2answers
167 views

Achieving server-side rendering of data coming from a PHP API

I have been working on a blog application with Codeigniter 3.1.8 and AngularJS v1.7.8. It is intended to be versatile and easy to use. The Dashboard of the application is "pure" Codeigniter, ...
0
votes
2answers
116 views

Should it be considered a BC break to return clone instead of new self?

(This question applies to the equivalent code in both Java and PHP) I have a class like this: class Foo { private int $bar; public function __construct(int $bar) { $this->bar = $...
1
vote
0answers
32 views

Best way to integrate google signin in existing user registration system with PHP/MYSQL [Logic]

I want to integrate google signin, in our existing user registration system. But not sure which approach will be good in terms of data security + user experience (UX) + speed. Even if its a good idea ...
-2
votes
1answer
46 views

Inheritance and domain-specific logic loses its independency?

Im sorry in forward, Im sure I wont be able to express myself well. Its a game system: abstract class GameType { private $score; public __constructor($score) { $this->score = $...
0
votes
0answers
17 views

Sanity Check Request on WordPress Problem involving Importing XML into Gravity Forms plugin

Disclaimer: This is a conceptual question and so I'm posting here rather than stackoverflow or wordpress.stackexchange Okay, so I need to import XML data into WordPress and parse it to populate a form ...
2
votes
1answer
149 views

Cross-cutting concerns and dependency injection

I've got a web application with an architecture somewhat like a front-controller MVC design. I get HTTP requests, route them, run them through a filter layer, dispatch them to my domain classes which ...
-2
votes
1answer
87 views

What are the names of the following patterns?

Two different patterns: Acting on a single object by multiple services that can modify it as they wish. So basically we would have some kind of a "chain" that modifies a single object by ...
2
votes
1answer
139 views

how to avoid / block e-commerce bots?

I am working in a big ecommerce platform from a very well known shoes brand here in my country, and our website have a page dedicated to a exclusive product This product sell just a few units, so by ...
-3
votes
1answer
67 views

Might be inheriting a php spagetti project. Full rewrite in different tech stack? [duplicate]

I'm in dire need of some help. My background is from python, js and ruby, with using frameworks to provide good structure. A potential client has an internal app which does quite a bit of stuff. This ...
0
votes
3answers
196 views

Is there an elegant way to structure consecutive short-circuited assignments?

The following code works and is clear, but it's also verbose. I suspect that there's a way to make it more terse, so that it could be skimmed quickly and it'd be more obvious what's happening. // The ...
-2
votes
3answers
73 views

How should I store file history in a MySQl data?

I am creating a web app with JS and PHP where users can edit a file similar to a text editor such as notepad. I've decided to use a database to store these files. One of the primary functions of a ...
-3
votes
1answer
114 views

What's the argument against complex type hinting in interfaces in PHP?

The more I write OOP, the more I realize that besides reasoning & structure, there isn't much for me and things make more sense if I combine that with functional or just straight-up non-OOP. Not ...
-2
votes
2answers
114 views

Prevent duplicate code in MVC

I have multi endpoint for my website ( Backend, Api, internal api for application and ... ) There is a lot of code that duplicate between this endpoints. for example for signup I repeat these lines 3 ...
0
votes
0answers
44 views

Best way to implement Shopify-like cache for products?

I'm currently building a shopping cart from scratch and am thinking of how I can cache the individual products as well as the product lists (e.g. Show All products page, Show 'Cakes' only page, Show '...
0
votes
3answers
93 views

Is this the return type covariance issue PHP faced when type declarations launched, violation of Liskov principle, or flaw in my pattern?

I've been using a somewhat odd yet effective pattern for a current use case. The one issue is that I'm getting an undefined method notice on a method that is unique to the subclass. The method of ...
0
votes
2answers
96 views

Instantiating a reference loop

For the following use case I tried to use (self-)reference loop. Use case A round based game what changes difficulty level after each round. The set of difficulty levels is fixed size. After each ...
0
votes
1answer
45 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 ...
-2
votes
2answers
35 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 ...
42
votes
8answers
8k 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 ...
-3
votes
1answer
51 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
44 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
41 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
275 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
172 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 ...

1
2 3 4 5
40