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.

1
vote
1answer
36 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
26 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
128 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. $...
0
votes
1answer
35 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 (...
-2
votes
0answers
52 views

Scaling PHP API for 1000 request per second

I have a task to design a POST API to serve 1000 request/sec. Right now I am developing on 4 cores 4 gb ram. From Apache ab it is showing 37 requests/second. <?php require 'vendor/autoload.php'; ...
2
votes
1answer
80 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
82 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
79 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
31 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
0answers
37 views

Reservation system design using PHP and Mysql

It's about one year that I've started developing custom management web applications, and for now I've made any kind of system, from the wharehouse custom management to the small local business. During ...
2
votes
1answer
104 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
211 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
138 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
55 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
50 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
151 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
55 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 ...
0
votes
1answer
73 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
33 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 ...
0
votes
2answers
123 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
77 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
62 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
65 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
82 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
140 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
136 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
84 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
93 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
67 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
193 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
157 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
71 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
106 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
99 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
67 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 ...
0
votes
3answers
163 views

Setter with one parameter and null default value

Which solution is most logical? The value can be null, but when not null it must be a string. This (First): function setValue(string $value = null); To me this is bad; since we can now call the ...
-3
votes
1answer
1k views

How can I do to use Angular 5/6 for frontend and Codeigniter 3 for backend in the same web app?

I have this project I want to do, using Angular 5/6 for frontend and Codeigniter 3 for backend. The problem is that I don't know how to combine the two, and all the tutorials I looked were using ...
0
votes
1answer
109 views

Structuring Code to handle Authentication

I'm developing code which will be responsible for creating new users and modifying existing ones via an API in a user management system. I have the authentication class developed, which handles ...
0
votes
2answers
138 views

am i asking for trouble? DB & dealing with variable item records

I feel this is so basic, but it just seems too easy and obvious and why didn't someone suggest this 10 years ago. And I know there a lot of much brighter people than me in the software dev business......
0
votes
2answers
142 views

Do i need 2 tables to book entity?

I am developing a website to store books info such (title, book_no, author, edition, container...). I have two types of insert insert series of books (Eg: harry porter series: chapter 1, 2,3...) ...
0
votes
1answer
163 views

Dependency Injection in one method to other method params

A teammate of mine wrote some code in the following way: Class Foo implements Job { // Framework uses type-hinting for dependency injection, only works on the handle() method // not on other methods ...
0
votes
1answer
129 views

Should the aggregate root have a property that it cannot validate [duplicate]

I ran into the situation where I have to decide whether a property belongs to my aggregate or not. My domain logic is the following. A User has a group in his organization ex: IT, SALES, MARKETING. ...
1
vote
1answer
63 views

Static data reuse

I'm going to describe the situation first and ask questions in the end. I need to validate a scalar value using the Symfony Validator component. The value is an associative array. Now I have defined ...
0
votes
1answer
155 views

Refactoring bad code switch statment without distort everything

Once in a while I’m stumbling on switch statements during a Code Review session. I would like to find a more elegant way of this code .... $istannceOfClass = $repository->loadFoo(); switch($...
-2
votes
2answers
191 views

How much damage can a rogue PHP developer do?

It's often convenient to hire a remote contractor for front-end development. Frameworks, like Laravel, use PHP to render front-end so it would make sense to give the front-end developer rights to edit ...
1
vote
0answers
40 views

PHP MVC - Single action for multiple similar views or one action for each?

For example, if I have 3 database tables that have similar columns/attributes: cats, dogs, bunnies Each table has a view that consists of an html table listing all records in the table, and a form ...
1
vote
1answer
173 views

How to pass a mock object into a class for unit tests

There seem to be many ways to pass a mocked object into a class for unit testing and I am unsure which is the proper approach to take for my PHP application. If I was using Dependency Injection then ...