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
0answers
7 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 ...
-3
votes
2answers
84 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 ...
0
votes
1answer
80 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 ...
-2
votes
1answer
46 views

How to implement security and authentication with a React/ Node.js and PHP based web app [closed]

First, I would like to say I understand if this may not exactly follow the general guidelines of a good question due to it's open-ended nature, but I do genuinely need advice on this subject. I am ...
0
votes
1answer
43 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
51 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
109 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
102 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
126 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
113 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
67 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
154 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
64 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 ...
0
votes
0answers
30 views

Design pattern for fetching associated entities

I have a User model which has "Payments" in quotes because depending on the user, there could be multiple sources of payments, like StripePayments or BraintreePayments. Instead of writing all the ...
3
votes
4answers
150 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
49 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
96 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
88 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
83 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
44 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
171 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
213 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 ...
1
vote
1answer
239 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
57 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
156 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
163 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
76 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
125 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
108 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 ...
2
votes
0answers
64 views

Performance: Creating duplicate file

I have a Web server (Local) and File server(Remote). I need to create a duplicate of an xml file in the same location with different file name in the File server. The size of the file is random, but ...
1
vote
0answers
75 views

What Design Pattern to use to render PDF pages for a PDF Proposal?

I want to create a set of patterns to use for rendering a PDF Proposal (a set of PDF pages). I have made a good start, but not clear on how to proceed when more complexity is involved. I am using ...
0
votes
0answers
29 views

How should I store multiple, related models when configuration control is required?

My problem: I plan to store a "project" in a database, where a project is composed of multiple items e.g. documents, and each document has multiple items e.g. paragraphs. Paragraphs may cross-...
1
vote
1answer
83 views

Should this part of my web-app implemented on server-side or client-side?

I want to write an application which monitors a few URLs (like a couple hundred) of all branches of school. By monitoring, we mean that it sends requests to those URLs at regular intervals (Interval ...
0
votes
1answer
164 views

Architecture / Design Pattern for Login Signup

I have a multi-seller ecommerce platform, derived out of Opencart 2.3. We changed quite a bit of the core code of the Opencart to add our own customizations, including features such as Seller ...
0
votes
3answers
139 views

How do I deal with file downloads?

I'm currently working on a script (in PHP, but I'm not sure if that's relevant here) which allows users to set up a simple file-sharing system on their server. I'm stuck when trying to figure out how ...
2
votes
1answer
71 views

How do I refactor a graph service to where I can encapsulate if/then/else statements?

I have a graph service where I use if/then/else statements. class GraphService { function getGraphData(array $products) { foreach ($products as $products) { $...
1
vote
1answer
147 views

Entities and polymorphic relationships

Lets say that I have a shelf on which I can put items that are shelfable (not sure if that is actually a word but you can understand my point). So I have the following: class Shelf { /** @var ...
0
votes
0answers
148 views

Codeigniter Notification System URL Structure

First I apologize for my english. I am trying to develop a facebook-like notification system with Codeigniter. I know it's much better technology, but it's not about using them right now. The ...
0
votes
1answer
43 views

Is it appropriate to have a template get “streamed” data while rendering?

I'm dealing with code that renders HTML pages. I'm cleaning up an old, messy PHP code base. Let's say I have a template that loops through a long list of rows in a database. I can load my data into ...
1
vote
1answer
80 views

MVC: How to use data model list in recursive views

I am trying to learn web app MVC in PHP.Most of the articles discussed about 1-to-1 MVC pattern given bellow Controller: gets user request & update model, Model: receives orders form Controller &...
0
votes
1answer
347 views

PHP MVC controllers using ajax

I'm learning to use the MVC pattern to design my PHP's software. I always use ajax to send requests to my controllers so often I've a code structure like this: <?php if(isset($_POST['action']) &...
0
votes
2answers
292 views

Should i use an abstract class or an interface for my doctrine model?

In Doctrine, assuming I want to implement different types of vehicles. Maybe a car, a plane, a bicycle and so on ... all these vehicles have many different properties but also very common things like ...
0
votes
1answer
72 views

Should I print to the page from a javascript object, or only render from PHP?

I have a complex app on the Javascript/PHP/SQL stack which manages different domain objects. The Javascript layer contains classes which manage the data on the client side. I am currently baking a ...
2
votes
1answer
108 views

if null is bad how we justify the “rfc” nullable for php language?

I do not understand how you think about it:https://wiki.php.net/rfc/nullable_types when It is widely confirmed, that using nulls is bad practice Where am I wrong? thanks. I'm not criticizing !. I ...
3
votes
1answer
101 views

Array rotation algorithm

I'm developing an application which sends quotes to clients via email. Since quotes are obtained from various resources (per each client) they end up in a single array which is then used as a source ...
3
votes
2answers
73 views

Where do I encode value conversion methods in an MVC web app to display values in different unit systems in the View?

I have a use case where I do internal data computations using English system, due to various precomputed graph coefficients and other data already using the English system. But for output I need to ...