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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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

0
votes
0answers
16 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
14 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-...
-3
votes
0answers
27 views

Contents of a web application

Currently I am working on a research of web application migration. So I need to clear my mind about the contents of a web application. I want to know whether a dynamic web application can have both ...
-2
votes
1answer
36 views

Get familiar and be more confident in a new (PHP framework) environment [on hold]

I began to work at a company which mostly uses a framework called SuiteCRM. I am familiar with core php and have experimented with cakephp, but I am stuck with SuitCRM. I have to ask my colleges ...
1
vote
1answer
56 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
115 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
126 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
68 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
51 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
35 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
42 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 ...
-2
votes
0answers
43 views

Ideal design for many tables using the same source

First I apologize for my English. Scenario 1 In Questions and Answers tablars, I keep the identities of related files in json format. Scenario 2 The "rel_type" field shows which table belongs to ...
-1
votes
0answers
23 views

MVC: How to pass latest data from model layer to view layer that maintains the data Consistency

I am learning MVC web apps in PHP.I want pass only model data to the view that can maintain the data Consistency.So every times the model updates its data, then it also updates the data in view. Here ...
1
vote
1answer
59 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
46 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
67 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
68 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
102 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
90 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
64 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
95 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
276 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
84 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
104 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
135 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
111 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
104 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
59 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
0answers
32 views

Building a graphql api in php, async or not?

Coming from a previous task of building a graphql api in node I was asked to do the same thing for php. We started defing the components/tooling of our project and we went for what we know best in the ...
0
votes
1answer
147 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
187 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
38 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
130 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 ...
3
votes
2answers
203 views

Should a trait refer to parent methods?

Is it a code smell if the methods in my trait refer to parent::methods or to methods that are assumed to be in the utilising class? A random (senseless) example trait foo { public function bar() ...
2
votes
1answer
88 views

How to create a cache-preventing link? Using random number? Unix time? or other better options?

For example, sometimes I need to generate a link, but I don't want someone cache the context by url of the same link (e.g.:I don't want Facebook feed dialog to cache the page context), so I need ...
1
vote
0answers
28 views

Storing laravel API tokens from one API in another APIs env file

Last year my company started using Laravel to build APIs, and we created two separate repositories - one for a primary API and then a second for a secure API that would only accept requests from the ...
3
votes
2answers
334 views

Dependency Injection in Chain of Command pattern

I have a Chain of Command pattern implemented, with modules that implement an interface: interface IRequestHandler { public function handle(&$offset, &$tripData, $request = null); ...
-4
votes
1answer
169 views

Android app using php mysql session

I am developing an android app. Backend code php and mysql. I can register login using php myql. But I want to add profile information using android app. But the information goes as another user id. ...
0
votes
2answers
70 views

The best approach for processing a large data on php

I am searching for the best approach for process a large amount data using PHP. I want to create a xml file from a database, when I execute my code the system will stop with a "PHP timeout" error, I ...
1
vote
2answers
221 views

Why does PHP needs Apache or Nginx

I am curious to know the reason that makes PHP not capable to act as a application server. Node has its own http server and for Python I know that they have couple of http servers based on their WSGI. ...
0
votes
2answers
101 views

Is it right to keep users permissions in php session?

I try to integrate permissions for user and I want to find the best way for that. I think to save all permissions of the user in the session on login, but when permission will be changed by the admin, ...
0
votes
1answer
89 views

Serialized Object Representation in Javascript from PHP

Let's say I have a Widget object that I serialize and send back to the browser at a regular interval. This Widget object includes lots of different members (variables) and other objects along with ...
0
votes
1answer
42 views

Separation of concern. Accessor methods and data sanitisation.

I have a great deal of 'dirty' data pulled from an API request. Before database insertion, I clean out a lot of line feeds and regex out values such as height and width from item descriptions. ...
1
vote
2answers
211 views

TDD workflow with integration testing

I'm having troubles with using the right workflow with TDD. Some people say we should design before writing any code, some say we should make a test, make it pass, then refactor the code and that ...
2
votes
2answers
95 views

Pattern for modulating an object based on a variable

I am writing some code that really smells but I can't figure out exactly why. I have documents that exist in multiple languages. I want to be able to serve a document in its requested language and be ...
2
votes
2answers
233 views

What's the difference between a Mixin and a Trait?

From what I can tell from Scala and Hack- Mixins: Can have state (ie. instance properties) Can only provide concrete methods Can have constructors, that are called in the same order that their ...
1
vote
2answers
830 views

Can I compile PHP to hide the code?

A pretty critical issue came up, which is more legal than technical, but I hope to find a lower cost technical solution. There are laws in some countries (I'll leave out name) where you have to keep ...
0
votes
1answer
199 views

Is it a good idea to load all user data on top of each file including sensitive information?

I've written a User class like this: <?php class User{ private $id; private $username; private $password; private $name; private $email; private $key; private $phone; ...
0
votes
1answer
89 views

Is there a coding style for Blade templates?

Since when I used smarty I always tried to separate logic statements from html tags, so my approach to blade would be to write: template.blade.php <div> <div> @if ($something == true)...
1
vote
1answer
105 views

ORM for 600 tables

I am working on a huge application in php which contains almost 600 tables to work with, not to mention it requires complex joining for 10 or 15 tables together. i wanted to ask how much ORM is good ...