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
-2 votes
0 answers
27 views

Saga Choreography in Request - Reply MQ

Preface I'm Currently working on a project of the following architecture: API Gateway RabbitMQ Using the SAGA pattern. our language of choice is PHP. What we want to do: A route receives a request. ...
user avatar
  • 1
0 votes
2 answers
136 views

How to refactor code so that a facade class could be decoratable?

I've got a class that is a facade class (encapsulates complex-ish behaviour for reusability). It has a function called manage (the class is called Manager): function manage() { $entityBuilder = '...
user avatar
0 votes
0 answers
50 views

CQRS, DDD and batch, CRUD-y operations

How to perform basic CRUD operations (especially batch) by playing with DDD and CQRS? Let's say I have a list of IDs in my controller that need to be removed (soft delete). Currently, I treat this ...
user avatar
0 votes
0 answers
62 views

Prevent users from creating "global" database connections for a forking general purpose server?

I've created a general purpose scalable server in PHP. It's scalable in that the main process merely listens for incoming connections and immediately distributes them to forked child processes which ...
user avatar
0 votes
2 answers
130 views

Decisions according to environment

I am trying to convince others that the following first code snippet is bad practice and the second snippet is best practice. Bad practice: // There is only one implementation of Adapter public ...
user avatar
  • 535
0 votes
2 answers
160 views

Share data between users without a database, php [closed]

How would I create for example a live chat, where you "post" a piece of text and it is displayed to other users in a "chat room", without the need of permanently storing it. My ...
user avatar
  • 23
0 votes
1 answer
106 views

Why doesn't PHP support function overloading (even though it supports type hinting)? [closed]

Why doesn't PHP support function overloading (even though it supports type hinting)? For example why we can't do something like this: function foo(Student &s) { } function foo(Employee &e) { ...
user avatar
  • 121
-3 votes
1 answer
44 views

Server performance and CMS scalability [closed]

I have been given the job of a colleague who has resigned and I don't know where to start. I hope you can give me some hints: It is about a CMS made from scratch (Javascript/jQuery/PHP/MySQL) which ...
user avatar
  • 97
0 votes
1 answer
83 views

How to concretize a return type when inheritance is used?

I have two repositories: class RepositoryOne { /** * @param int $id * @return ModelOne */ public function getById($id) { // Search and find a ModelOne model in the ...
user avatar
0 votes
2 answers
100 views

Design patters for handling invoice "payment_status" when split payments are involved

Requirements I'm building a system with the following requirements. An Invoice can be paid using multiple Payments (e.g a customer pays the invoice in 2 installments) A Payment can be allocated to ...
user avatar
  • 109
0 votes
1 answer
70 views

Strategy pattern with implemented public method

New to design patterns so my question maybe silly. I want to use strategy pattern for returning data from a databases in the same format. Nevertheless it varies the query on the underlying database ...
user avatar
2 votes
1 answer
164 views

Static validator in DDD value objects

I have a value object to hold a user id number as a string. This number has a unique format throughout my domain. So, it's being validated inside the object during instantiation and an exception is ...
user avatar
1 vote
2 answers
118 views

QR Code Scanning with location check

I would like to make an order-system with QR-Codes which is online. How I imagine it to work: A customer visits a restaurant. There is a QR-Code on his table which takes him to a public webpage where ...
user avatar
  • 19
3 votes
4 answers
2k views

How to store a password so that it can be passed to another site/service which is expecting a plaintext input

I am developing a website and I would like to allow users to use XMPP for live chat. I would like users to have the option use an existing XMPP account if they wish and store their XMPP username and ...
user avatar
0 votes
0 answers
24 views

DDD & ES – modeling crossing context between domains

I've been experimenting with DDD, CQRS and Event Sourcing recently as part of a small application I'm writing for my own use. Unfortunately, I'm not quite sure how to play some things out correctly ...
user avatar
  • 1
0 votes
2 answers
60 views

Getters and (static) processor vs multiple processor wrappers

I've got a class which stores two data series like so. I need to do some complicated processing on each of these arrays, but for now we'll just get the average of each data series. I could either do ...
user avatar
1 vote
1 answer
72 views

What is the best approach to use a common variable in multiple method in a request in laravel [closed]

I have a $c variable that is calculated at the beginning of the request. After calculating this several nested methods use it as a part of their job. Is it better that I pass down the $c variable to ...
user avatar
  • 121
2 votes
1 answer
120 views

When is it Counterproductive to Separate PHP and HTML

Understanding that it is less load on the server to not have to parse HTML, when does it work the other way, as far as server performance. The majority of my Web sites are database-driven - often the ...
user avatar
40 votes
7 answers
10k views

Why do library developers deliberately break existing code?

Today, I updated ZBateson\MailMimeParser the PHP e-mail parser library from 1.x to 2.x. Soon enough, my PHP error log started filling up with errors. Noting where it happened, I found out that it had ...
user avatar
-1 votes
1 answer
87 views

Adapter pattern for formatting third party API responses

I've been refactoring some of my procedural code to OOP, and I'm wondering if using the adapter pattern is overkill in this case. Basically, I created a Order class. All class properties are a field ...
user avatar
  • 11
0 votes
0 answers
27 views

Best way to see changes to non-monitored linked tables

I am hoping that I can get feedback on my solutions, and other ideas as well. We have a table in a database being monitored by a NodeJS app, using the MYSQL binary logs, E.G.: ORDERS: orderID, ...
user avatar
0 votes
2 answers
235 views

How to measure the benefit of replacing big parts of the HTML DOM vs doing a new fresh request?

I am looking for a method to measure the time difference between: the time it takes to load and completely reach TTI for example.com/page-B given that example.com/page-A is loaded. the time it takes ...
user avatar
2 votes
4 answers
338 views

Would this violate the Liskov Substitution Principle?

Say I have a set of objects from an "old system" that I want to convert to a newer set of corresponding classes. Each specific class has its own way of being converted. So I have this: ...
user avatar
  • 159
0 votes
1 answer
50 views

"Subtractive" behaviour extension vs overriding a function completely - what are the pros/cons?

Lets imagine some vendor code that we want to extend on our project level protected function getDefaultFormClasses() { return [ new FormClassA(), new FormClassB(), new ...
user avatar
  • 243
0 votes
1 answer
65 views

How to prevent mutual dependencies when implementing database relationships

To explain the problem imagine you have two entities User and Group. The OO implementation has two classes UserModel and GroupModel. UserModel should have a method getGroups() (returning instances of ...
user avatar
  • 101
1 vote
1 answer
96 views

Is it a bad idea to put each class method in its own file? [closed]

We have an existing project that has grown very messy and confusing; our classes are huge and difficult to read. Our boss wants us to break all of our methods out of the classes and into separate ...
user avatar
  • 11
3 votes
3 answers
176 views

Build once or twice: how to synthesize advice from PHP's Composer package manger manual and Continuous Delivery

Authors such as Dave Farley advise us to "only build packages once", so that we can "be sure the thing we’re deploying is the same thing we’ve tested throughout the deployment pipeline&...
user avatar
  • 1,976
1 vote
1 answer
127 views

Visitor pattern applicable ? - Applying rules to a list of registrations

I have a list of Registration's, on which I need to apply a set of rules to each individually. Rules can be a single Rule, or a sequence of rules, representable by a tree. One rule is a ...
user avatar
  • 119
-2 votes
1 answer
222 views

Structure project by inheritance?

The usual approach is to do what libraries do: group your (single file) classes by component where folder = namespace, right? That makes sense for code that is mostly meant to be used by other ...
user avatar
  • 105
0 votes
1 answer
42 views

Improve performance of single tenants on shared server

I'm trying to improve the performance of our server. We have 1 server with around 25 tenants, each tenant has it's own application instance and database. There are no performance issues, until, each ...
user avatar
4 votes
2 answers
286 views

Is there a canonical definition of SPA or is SPA a broadly agreed-on architecture with fuzzy edges? [closed]

Is there a canonical definition of SPA which would exclude the software architecture model described below? I'm working on an app with a new web-architecture model (new to me, at any rate) which has ...
user avatar
2 votes
4 answers
539 views

Do all dynamically typed languages not support function overloading?

I have noticed that JavaScript and PHP and Python do not support function overloading. Do all dynamically typed languages not support function overloading? If the answer is yes, then why is that?
user avatar
  • 55
2 votes
3 answers
266 views

Is it best practice to always try to return a minimum number of rows from the database?

First-time poster so please be gentle :) I have a rather large table in my database (MySQL in case it matters) that holds lat/lng values of certain points of interest around the world (table name: ...
user avatar
  • 131
-1 votes
2 answers
200 views

PHP Design Pattern, separation of concerns: should the Controller make a new HTTP request to the API?

I'm having a huge doubt on how to connect the front-end of my application to its back-end. So my application has a single entry point where all requests go. The request is dispatched to a controller, ...
user avatar
2 votes
2 answers
129 views

Use old legacy application code from new application

If you have a big legacy application (big ball of mud), lets call it MudApp. If you then create a new application to make us of new technology and to make a new good looking frontend because that was ...
user avatar
  • 59
15 votes
6 answers
7k views

Should I use DATE or VARCHAR in storing dates in MySQL?

Simply put, I have date and time attributes on an Orders table. The data types for these attributes are MySQL's DATE attribute. But everytime I echo the date and time in PHP it just gives me a string, ...
user avatar
  • 215
34 votes
9 answers
10k views

Is it good practice to echo PHP code into inline JS?

I'm new to PHP and JS and I'm currently working on a gym management web app for our project in school. I'm adding a bit of QR functionality that sees if the user is eligible to enter the gym or not by ...
user avatar
1 vote
1 answer
229 views

In which layer should I load views on a Clean(ish) architecture?

I am trying to organize my architecture following the clean architecture while using some common practices/frameworks. I'm writing in PHP, but have no problem with other languages. The flow of my app ...
user avatar
1 vote
1 answer
182 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 ...
user avatar
-2 votes
1 answer
57 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 ...
user avatar
  • 97
3 votes
3 answers
298 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 ...
user avatar
  • 336
1 vote
4 answers
264 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 ...
user avatar
-1 votes
1 answer
72 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, ...
user avatar
  • 17
2 votes
0 answers
69 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 ...
user avatar
0 votes
0 answers
73 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 ...
user avatar
-4 votes
1 answer
62 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 ...
user avatar
-8 votes
1 answer
105 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 ...
user avatar
55 votes
11 answers
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 ...
user avatar
2 votes
0 answers
193 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 ...
user avatar
0 votes
2 answers
213 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 ...
user avatar
  • 119

1
2 3 4 5
41