Tagged Questions
Questions about PHP, a widely-used general-purpose scripting language that is especially suited for Web development.
1
vote
0answers
31 views
Procedural PHP Framework Concept
So I had this idea to map my framework's folder structure to namespaces with a dynamic build process.
To give you an idea how this would work here an example structure:
src/
FS/
File/
...
0
votes
0answers
30 views
Project Structure for intermediate level abstraction
This is really a question on higher level naming.
We have an API directory for classes that deal directly without outside APIs, and contain all the code to consume a specific API. We call this lib
...
1
vote
1answer
64 views
RESTful api and nested resources
Having built a RESTful API (using Laravel) for a project at work, I followed what seemed (from lots of reading) to be a the majority in terms of my approach to nested resources - by defining them in ...
0
votes
0answers
51 views
How can i maintain clients data on browser side ? Like their selections and userid's
How can login of a particular client can be maintained in browser side.
Which concept can i use for this? I have to maintain their session login even after client closes the browser till he/she opens ...
2
votes
1answer
69 views
+50
Impacts of using class_alias() to maintain backwards compatibility in PHP
Scenario: An open-source PHP project that has existed for several years has too many classes in the main namespace that we want to refactor some of them into another namespace, but we have a widely ...
0
votes
2answers
161 views
Need advice on making my own custom URL shortener?
Due to some issues with other shorteners like goo.gl (disabling my links for example) I want to create my own URL shortener.
I am looking to have a single table that will contain the following ...
0
votes
1answer
71 views
sending ajax request with setinterval . is it good?
I am developing a website where client needs that any notification should reach as soon as it is created. so i am using setinterval function of jquery and using ajax requests to get the notifications. ...
0
votes
0answers
44 views
Properly translate MVC view
I have not been able to come across too much information on this subject. In a PHP developed MVC app, I have a class method used to translate strings, if a translation for that string exists.
public ...
0
votes
4answers
125 views
How important is it to have multiple action per one page load?
In conventional web application there is single action per one button click from user. So clicking on submit form, send email or change status, delete user etc all this does single action per page ...
0
votes
0answers
15 views
Extend inherited object structure from library
I created a base library/package containing the class Type and its childs ObjectType and PrimitiveType.
In addition to that, I have 3 different use cases for this type classes that logically belongs ...
4
votes
2answers
70 views
Permission system using PHP and JS
I'm developing an admin dashboard with different areas, where different users may have different permissions. For example:
News
John: edit, view, add, remove;
Carlos: edit, view;
Mario: --;
Support
...
0
votes
2answers
81 views
How do I manage too many functions in PhP (or other programs)
I make very long programs. There are many files.
Basically I have too many function.
Every code can pretty much call every function.
If I want to pull out some function and store it as a library so ...
4
votes
2answers
97 views
How do I know when to refactor global database query calls, and when to leave them alone?
I have the following global statement calls sprinkled throughout my PHP legacy codebase:
$jobnumber = db_quick($sql);
db_query($sql);
That is, those function calls have been initialized in the ...
0
votes
1answer
22 views
How can I integrate views with controller state transparently?
In a MVC application, integration between controller and views are often a matter of:
class HelloController {
public function sayHello(Request $request) {
return new Response($this->...
-3
votes
0answers
48 views
Frontend to Backend workflow
Right now the frontend dev hands over static html files to the backend dev who then includes the php code. When the frontend changes this step has to be done again. What would be the right way to do ...
4
votes
1answer
206 views
is it common sense to convert database data to object first?
In the framework I am using, I shall group things into models, controller, and views (I added services).
When getting things out from database, it is pure data in array form. So they won't have ...
8
votes
2answers
331 views
Why PHP treats “0” as FALSE in boolean contexts?
"0", as a string containing one character, is not something empty intuitively. Why does PHP treat it as FALSE when converted to a boolean, unlike other programming languages?
3
votes
2answers
80 views
Using PHP traits to simulate multiple inheritance
For this question I want to present my current design and my idea of using a trait. I would like to know whether my understanding of traits is correct and whether my problem can be solved with another ...
2
votes
2answers
83 views
How to validate ajax request comes from correct page and is not tampered with?
I am building a simple Q&A app with PHP, HTML and JS. I have three tables: users,question and answers, each table has it's own primary key and questions and answers both have foreign key ...
-1
votes
1answer
48 views
Sql server to PHP (api vs library)
Our agency is currently using and maintaining the CMS we have developed in .net MVC on SQL server.
Since the cms is highly optimized and uses various cache tables to run very fast even with thousand ...
0
votes
1answer
56 views
Working on Cloud app without connection
I am creating an application based on the cloud for the management of articles. I'm also a desktop developer so I never had problems with the internet absence, mainly because I was working with db ...
-1
votes
1answer
40 views
php algorithm for picking next person up in round Robin fashion
Okay, I have a list of people in a database, can you point me to some sample coding that will show me a good algorithm to determine who the next person in line is?
Because people can be added to the ...
0
votes
1answer
93 views
How do I examine & maintain a PHP image board script with little, to no experience, in cpanel hosting?
I currently work for a company that has hired me to manage a website that has been installed by a former developer.
I have access to the cpanel host and hold 100% authority to the website.
with that ...
1
vote
1answer
69 views
Relations between entities in DDD
I am a beginner on DDD, working around small, simple domains in order to get my head on all the principles of design.
I have this simple domain: institutions (Institution) and their available WiFi ...
0
votes
1answer
83 views
Handle cron jobs for multiple timezone
How to handle cron jobs for multiple timezone?
I am working on the PHP project that supports users from multiple timezones. I have used multiple cron jobs for multiple database operations.
I am ...
5
votes
1answer
116 views
How much of the data preparation, transformation, and processing belongs in Repository layer?
I have a use case where I display variables in a PDF file. But to get there is not simple, but I could do something like this:
/*
* takes product model number, retrieves, processes, formats values
...
0
votes
1answer
63 views
How to analyse user input and determine if it (kind of) matches an answer
I'm working on a quiz system that will allow users to enter text as an answer. The question could be something simple to start with, looking for a short phrase, or a select few words as the "correct" ...
0
votes
0answers
27 views
Where to place custom classes in Slim3 PHP application
I'm currently developing an application using Slim3 and at the same time learning how to structure applications correctly. I'm a bit lost when it comes to structuring the application correctly.
My ...
5
votes
1answer
48 views
Can class DBQuery be merged with or extend class DBConnection?
This is question about class relationships not class functionality.
Currently my DBConnection and DBQuery classes are two separate objects
class DBConnection {
public $dbh;
__construct() {
...
5
votes
1answer
87 views
I have a class for creating objects from a database row. How to design a class to perform functions on all rows e.g. counts on db table
Say I have a database for storing cars data. Each row is essentially a car and I've a class that takes a row of the data and builds my car object.
I now want to build a dashboard that can tell me all ...
4
votes
1answer
67 views
Changing webapp design/arch to make it easier to maintain (scalable)
Lets say I created a webapp that I want to make it more scaleable.
How it would work now
If I want to "sell" the webapp I have to do the following:
Rent a new hosting
Copy the code to the hosting
...
2
votes
0answers
61 views
PHP OOP best practice to split low level class into two
What i got now is low level object that has bunch of methods and its difficult to navigate trough i want to break it down, however functions logically have same functionality just different ...
2
votes
1answer
151 views
Does if-else optimization in PHP has any effect?
Consider a scenario, where A occurs frequently like 4 out 5 times, and B only in rare cases, we can write our conditional statement in two ways:
if(A)
//do something
else
// do something if B, only ...
1
vote
0answers
36 views
How to implement my own CMS hosted on a remote domain in all my projects?
So, I'm developing my own CMS which dynamically adjusts to the settings I have set on a specific domain.
I just developed this whole CMS on my local machine and now facing the problem that I have ...
1
vote
2answers
70 views
CSV file processing in MVC
I am using a MVC framework and I have developed a module where .csv file is being imported into the database, I am little unsure about certain things which I'll try to explain below:
Step 1:
.csv ...
2
votes
1answer
177 views
How to reduce “mapping” code?
I have two components, both are a parser/builder pair. So component A can parse A and build A, component B can parse B and build B.
A and B both contain different entities, which are extracted by the ...
1
vote
3answers
156 views
Pros and cons of designing PHP application with one public file approach?
I have an idea of making application in php that will not have any public files other than index.php i.e. different pages of project load as parameters sent to index.php
Also if someone wants to ...
1
vote
2answers
123 views
Managing session timeouts with regards to user activity in the page
So I will be creating a feature to a php application that does the following:
Create a session that expires after 30 minutes.
After 30 minutes, if there is no user activity in the application (...
14
votes
3answers
792 views
I'm losing track of the flow of my PHP web app, it's becoming hard to work with
I've been programming for a few years, and have become very familiar with C# and JavaScript over time. I have some larger C# and JavaScript projects that I have no trouble navigating around. I ...
2
votes
2answers
263 views
Is it good OOP practice to pass object to object and have more than one instance of class?
Singleton pattern saying "there should be no more than one instance of same class", is this something one should stick to when designing PHP OOP applications?
What are advantages / disadvantages?
...
1
vote
2answers
81 views
Storing user search terms
I have php application like airbnb. I want to store search values each time user search for listings.
my number 1 solution would be storing it in mysql table, but I'm not sure its wise to do, if site ...
1
vote
1answer
53 views
Fast and memory-optimized checking for values in database using php
I have a function to generate n random string with the same length, making sure there isn't any duplicates, and then saves them to the database. Right now, to speed things up, first I get all the ...
1
vote
1answer
78 views
Converting a large PHP codebase from mysql_ to PDO [closed]
At my workplace we're soon going to be tasked with removing SQL injection vulnerabilities from a large code base. The application was originally written around 8 years ago and after years of bolt-ons ...
1
vote
1answer
73 views
multiple php page within a main php page
Is it ok if I include many PHP file within a PHP file? What is the best practice? Or where can I learn the best basic practice of writing PHP?
Why I do this
Is because I often can change the content ...
2
votes
2answers
156 views
How to think in Object Oriented way when it comes to passing messages?
Somewhere I have read that "Object Oriented" is a misnomer and that OO should really stand for "message-oriented programming".
What I am not clear about is ... what does it mean? For example in ...
3
votes
1answer
150 views
Is there a name for a design technique where an object's method takes input and returns custom business object?
What do you call a class that has methods that
take input (from user, from GET or POST)
transform it to a business object and return that object
example ...
class Input
{
function getObject(...
2
votes
0answers
61 views
How to trigger other events in MVC, once the desired event completes?
What is a technique in MVC that can be used to trigger updates?
Namely,
When user clicks a button save a product I have this:
function saveProduct($product)
{
$this->repository->...
6
votes
3answers
224 views
How would you go about making a search algorithm for a CRM?
I know this question is kind of broad, but all I really need is some best-practice code structure or a link to a good tutorial.
I am working on a CRM that runs on php and mysql. Currently, our search ...
1
vote
2answers
162 views
Is it bad OOP practice to have any independent procedural code outside of classes definition?
In large PHP OOP application is it bad practice to have procedural
code outside of class definitions i mean that works independently
from objects? e.g. intertwine OOP and Procedural code in same
...
4
votes
0answers
65 views
Best way to access a logger across an application/website in PHP
I've recently read up on PSR-3 and am interested in learning about the best way(s) of approaching a logger implementation across a web application or website. I understand how a logger is defined and ...