Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [php]

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

0
votes
1answer
44 views

Migration benefits from PHP web app to java?

I have recently joined the company which took the call to convert the PHP based web application to java. The call was taken around 4 years by some architects who have left the company. I read a lot on ...
0
votes
4answers
101 views

Is there a pattern or best practice for returning dynamically typed data?

I have a method that returns the percentage change of a data in a certain period. After calling that method, i need to know if in the current period the data increased, decreased or is the same when ...
1
vote
2answers
80 views

Should you “rebrand” the exception of the library you're using?

Say your making a library Foo that depends on a 3rd-party library Bar. Bar throws a custom exception \OtherVendor\Bar\CustomException. Is it recommended to just throw that exact exception to your ...
-5
votes
0answers
17 views

How to give Users B, C, D access to user A's page? [on hold]

What would be the best way to give access to user A's logged in webapp page to his/her team members? A link to the page will be send via a html sms tag. The team members will not be in the webapp's ...
0
votes
1answer
69 views

Is singleton use acceptable for static single responsibility?

I have been reading into possible design patterns and have found the use of singletons always referred to as an anti-pattern. I am currently using a singleton for the sole purpose of gathering ...
1
vote
3answers
42 views

Integration Testing: Should a test check every validation?

I am somewhat new to writing tests and I want to build that habit into my workflow. So for example I might write a test that a user can create a blog post however I'm not sure on how to do that ...
0
votes
1answer
23 views

Database abstraction layer

I'm currently developing an SaaS application in PHP, with Laravel, using its own DB class. Let's pretend we've got 2 classes under 2 namespaces, plus Laravel's own DB - so Illuminate\Support\Facades\...
0
votes
0answers
30 views

Role Based Access Control on OOP how do you map Permission of Role to Entity?

I've been trying to wrap my mind around this RBAC system. The goal is with a static method from a class, I can get the current user/actor, then check if he has capability to do something for specific ...
-6
votes
0answers
26 views

Real time table for availability of participation at courses

I need the start point for a WordPress procedure. I need a chart which shows in real time informations about the availability of a course. The participant has to see in real time if there are still ...
-2
votes
1answer
60 views

PHP MVC - which approach is the right one

Next semester we'll learn the mvc pattern in web development but since it looks pretty interesting to me i decided to learn it now but...there is a problem. Surfing trough the pages i found two ...
0
votes
0answers
50 views

Getting into situations that requires mixin while building classes. How should I correct my class design?

I have the following classes for to solve a particular problem related to HTTP responses. Problem is for class ServerSentEventStreamResponseService I am in a situation where I need mixin because I ...
0
votes
0answers
23 views

Considerations for delegating long running to CLI from PHP/Apache

I'm working on a web project that executes CLI commands to perform running tasks to spare users from having to wait since PHP/Apache combo cannot (to my understanding) create a separate process for ...
2
votes
0answers
44 views

Restructuring PHP application classes

I'm trying to modernize a very old PHP application for a customer to keep its code base up with modern coding standards. I am permitted to restructure things a bit, but dumping the entire app and ...
0
votes
1answer
32 views

Updating a distributed backend and keep track of compatible releases for Electron app + Webserver (PHP + MySQL )

Currently i'm working on a small platform with a simple client-server model and will soon go in a closed beta with a launching customer. In essence it's an Electron application which is mostly used ...
0
votes
0answers
69 views

Which architectural patterns should I use for a decoupled notification system?

Background The application I work on use a command bus to handle events (REST API HTTP requests, commande line interface). This bus is built using the well known league/tactician package. Feature to ...
-4
votes
1answer
74 views

Public var vs protected var and get function [closed]

I've noticed this style of code a lot in frameworks like Symfony and Magento 2 (which is based on Symfony): <?php class Foo { protected $foo; # construct function - not ...
2
votes
5answers
245 views

How do you force developers to define dependencies/arguments if it's bad to put the constructor function in the interface?

I just started reading more about OOP and its design patterns and is confused with this conceptual question. I am too new that I am having second thought that the proper title should be, "when is it ...
0
votes
1answer
64 views

Folder structure for child classes

I have a user feature. user feature also has other subfeatures user application details and user contact information. Usually, because application details and contact information are part of user ...
-1
votes
2answers
59 views

Design Pattern to wrap a series of step

I'm already posting this question on StackOverflow, but thought that asking it in different communities might give me different insight. So here's the repost of the question: Hello, I'm having a ...
0
votes
1answer
52 views

Using the adapter design pattern for a news application microservice

I am currently developing the backend for a news application, which fetches news from various aggregators (e.g. Feedly). I thought this qualified as a good use case for the adapter design pattern, so ...
-4
votes
2answers
95 views

should i create db functions in MySql rather than Php code?

I have a MySQL database and I am working with Core PHP. What is the best practice in terms of accessing the database? Should I create functions in MySQL and access them in my PHP-code OR write ...
1
vote
1answer
88 views

Secure Admin-pages-only login without HTTPS

I'm adding admin dashboard to a website that doesn't use HTTPS. For now only that (admin) section requires user authentication. If I use encrypted + salted password and check the client IP address to ...
0
votes
1answer
51 views

Modeling entities for company invoice management software

I am making a software to store all my company invoices (and then infer some statistics about it). The idea is: My company issues invoices to it's clients. My company receive invoices from it's ...
2
votes
2answers
62 views

PHP Sort question

I have a camera based security system that uploads all its images via FTP to a folder in one of my hosting accounts. (FYI, I use it to watch my cats when I'm traveling). So I created a PHP file to ...
0
votes
2answers
114 views

How can I force an object that respects an interface to output a certain data type / structure with its functions?

This is exactly my code, I'm just stripping out everything that isn't needed: First of all, I met this issue a lot of times and something tells me that it's something to do with PHP itself and "data ...
0
votes
1answer
111 views

How to handle complete rewrite of a file in regards to code review

My situation is this: I am contributing to a Symfony/PHP project. I had to completely reskin one page in the application. The controller logic is almost totally unchanged. I only had to change the ...
0
votes
2answers
145 views

Where should permissions be stored in a micro services architecture

We are currently in the process of building a service (a REST API) which is called on by our primary application. The primary application contains a users/permissions/roles set up which is used to ...
1
vote
1answer
117 views

How can I make sure my PHP code is compatible with a newer version

I have a bunch of PHP 5.6 code that I would like to get up to 7.2. My biggest concern was the change that causes an error when you call a function without enough parameters. Previously, this was a ...
1
vote
1answer
33 views

How to collaberate UI Team & Development Team for smooth development process over time to adapt changes in design?

The UI team deliver the HTML files to the development team. Developers code PHP on html files to make the website. But later we face a lot of changes in design. The designing team makes the changes in ...
0
votes
1answer
71 views

Unit tests involving library functions and objects

I am making a project using the Laravel framework. I plan to create unit tests for my project. But I feel I don't really have an idea what to test because I mostly use library or framework functions. ...
0
votes
1answer
218 views

Should the function that operates on the object return it?

Should the function that operates on the object return it? Shortened example: class Example1 { public function method($a, $b) { $result = new Result($a, $b); $this->...
0
votes
1answer
41 views

Some Questions on PHP execution?

I am new to PHP . I have primarily worked on java. I want to run the helloworld program for PHP. I got it how to do it through blog But I have got some basic questions :- Do I need to install both ...
1
vote
1answer
138 views

How to get email from Gmail to a PHP app

I'm building a PHP app which should somehow receive emails that are to be imported into user records. None of the solutions I've come up with will work (listed and explained below). I'm hoping ...
3
votes
4answers
154 views

How are account balances persisted

I am currently building a finance application that contains "accounts" Each account has a balance that is dynamically generated based on platform charges vs payments. e.g simplified example. $...
-2
votes
1answer
50 views

Web Security (PHP) - Is it Secure to do downloading files & presenting with Headers to the End User ?

I have security question that i am not sure if this approach is safe and secure way to download a file and present to a web user ? We have customers invoice files stored in a server location (...
1
vote
1answer
144 views

How to white label my website in php

I have a website that follows the following structure: www.example.com/city1 www.example.com/city2 ... Programmatically we change the logo which is hard-coded in a specific config file for city 1, ...
-2
votes
2answers
91 views

Same interface in constructor class but reference to concrete class

during my work my collegue push one class that have an costructor with two parameter of the same interface but he has used the reference to the concrete class. I wanted a comment on this scenario ...
0
votes
1answer
107 views

Is this a 'proper' use of a trait in PHP?

In Laravel 5.6 an Illuminate\Database\Eloquent\Relations\BelongsTo relation was given the ability to support default models. This allows a model that will be returned if the relationship is empty. ...
1
vote
1answer
46 views

Using the objects retrieved at the time of request validation

I hope the question title already answers the subject here. Lets say I have a number of ids that needs to be validated in a request. Example: request uri: [POST] /album/{album_id}/song Request ...
2
votes
1answer
284 views

Java and PHP compiled vs Interpreted and runtime environment?

I have primarily worked on java. Now Learning PHP. After reading couple of articles on google, i got the understanding but got some doubts too. Compiled vs Interpreted Java Compiled language :- ...
0
votes
2answers
217 views

What makes PHP a language and jQuery a library?

PHP is written in C, but is considered a language. What makes it different from something like jQuery which is considered to be a library of Javascript? Why is PHP not a library of C or jQuery a ...
2
votes
1answer
316 views

How can I turn my CRUD database application into a REST application?

I may have gotten myself confused, when reading CRUD vs REST and how they are similar, so I wanted to explicitly ask: can I turn my CRUD application into a REST application, when I have a specific ...
2
votes
0answers
58 views

Coupling form fields to functionality: using a Command Bus?

I built an app where the app owner can build custom forms for each of his clients. The forms have default fields like "name" and "message" as well as custom fields for each client requirement, like "...
1
vote
0answers
234 views

Handling complex dynamic queries in Laravel 5

I am developing a project using Laravel. My workflow is: route directs to controller Controller calls eloquent models Eloquent models perform queries (tipically CRUD and find) Controller returns ...
0
votes
3answers
175 views

PHP How can I get rid of redundant if statements

I have a bunch of if statements written in PHP for a project I'm working on. The pattern is that when the $price increases by 5 cents every time magazines are increased by 10. When the amount of ...
-2
votes
1answer
58 views

Using a class as an attribute in another class or just one value?

I have a PHP script which has a group class and a component class. Each group consists of several components. My group has attributes groupName, groupId and componentList. My component has a ...
-1
votes
1answer
78 views

Is Dependency Injection A Standard in PHP and Laravel?

Or in actuality, how to tell if a certain technique has became a standard in certain language / framework? As I understood from my readings so far, PHP supports DI in PSR-11 while Laravel uses it out ...
-1
votes
1answer
34 views

How to find the best match (set of options) among several sets of options?

Imagine a couple dozen services (sets of options), each of which contains a subset of all available options. I want to create a web form listing all possible options so that users can check the boxes ...
-1
votes
2answers
128 views

Handling logging when there is no internet access

I'm developing an application that handles sales for multiple clients, when the client sells a particular item, that information should be send to the admin. The count of each item sold and the item ...
0
votes
2answers
194 views

Require_once in class files

I have a big system of classes and objects which rely on each other in order to function. Should I put all of the require_once() calls for dependencies at the top of each class file? ie: <?php ...