Questions about PHP, a widely-used general-purpose scripting language that is especially suited for Web development.
0
votes
0answers
21 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 ...
0
votes
1answer
47 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 ...
0
votes
3answers
137 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 ...
0
votes
2answers
72 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 (...
11
votes
3answers
596 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 ...
1
vote
2answers
243 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
votes
0answers
55 views
Question about security of php login page
i'm working on a CLI open sourced project who generates Virtual Hosts for apache 2. But i understand that using command line is less practical for some persons than using a web panel. So i decided to ...
0
votes
1answer
44 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
votes
0answers
64 views
Why one should follow MVC to the word? [duplicate]
After analyzing MVC parrent for PHP i come to conclusion its nothing more than template language essentially, and greatly overemphasized as something genius and cool is just a hype.
Lets look at it:
...
0
votes
1answer
48 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 ...
0
votes
1answer
74 views
Converting a large PHP codebase from mysql_ to PDO [on hold]
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 ...
0
votes
1answer
63 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 ...
1
vote
2answers
136 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 ...
2
votes
1answer
139 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(...
1
vote
0answers
54 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->...
5
votes
3answers
216 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 ...
0
votes
2answers
154 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
...
3
votes
0answers
55 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 ...
1
vote
0answers
55 views
CSV scheduled upload with quotes and delimiter inside values [closed]
The requirement is to upload to my WAMP stack on a scheduled basis a CSV downloaded from a web tool that I don't control. The CSV file is delimited by commas and enclosed by double quotes. The issue ...
0
votes
0answers
44 views
unit testing a mocked class [duplicate]
I'm currently writing unit tests for my PHP code. I've read that unit tests should not interract with external elements such as network and filesystem.
In my code i have a curl wrapper class to ...
0
votes
3answers
158 views
PHP/JS software copy protection
First of all I know nothing I can do that 100% prevents illegal copying of my software. I'd like to just make it reasonably hard for a competent person to do, and almost impossible for an ...
1
vote
1answer
67 views
How to use object oriented principles to design a system that trims, selects, and formats values based on business rules, and unit measuring system?
TL;DR:
I have bad, no .. horrible, horrendous code that kind of works but is a mess and is not easily maintainable.
I want to redesign it and repackage it to where objects are well defined and ...
-1
votes
0answers
14 views
SEO regarding error redirect [migrated]
I have a product view which is required if a product exists through the link like
www.example.com/products/product-name
If the product does not exists, the error view is displayed instead rather ...
0
votes
0answers
61 views
JSON APIs in PHP, across the internet
I am building a proof of concept for data processing web service, that allows users to get data cleaned, homogenized or otherwise manipulated.
Often users send different types of data in the same ...
0
votes
0answers
34 views
In browser form validation in laravel
In laravel 5 I describe models without specifying fields in model class. Some magic identifies which fields exist in database for this model.
use Illuminate\Database\Eloquent\Model;
class MyModel ...
0
votes
2answers
99 views
Multiple tables with same name, but each with a unique id to distinguish them?
I'm trying to code a dice game where users log in and then challenge each other. I already made a version of this game without login but only one game could be played at a time.
So now, there will be ...
-3
votes
1answer
76 views
Is there any benifit to using a PHP class to handle MySQL queries?
I know several frameworks have this functionality built in where you can use their special methods to make DB queries. I also know this is (partially) to ensure that everything is handled correctly to ...
1
vote
1answer
30 views
What are some reasons to keep using lazy initialization when calling Doctrine's EntityManager?
Is it generally a good idea to use a function method to call Repository when using Doctrine?
I have noted that instantiation of EntityManager in Doctrine is an expensive procedure. There are some (...
0
votes
1answer
102 views
OOP design in php
So I have to create an object design for this application, it is just problem for practicing.
You are building application that will load data from several
different advertising systems and then ...
2
votes
1answer
108 views
How to consume external RESTful API with Symfony?
We are building a Microservice architecture for our projects, with mostly front-end Symfony applications interacting with back-end RESTful APIs.
The problem is this approach is breaking the Symfony ...
0
votes
1answer
112 views
How to handle JWT expiry in Laravel 5.3?
I am developing a mobile application back-end service using Laravel 5.3. I am following the REST API. The application has payment gateway integration and it needs more security.
I followed JWT auth ...
0
votes
2answers
120 views
Which programming technique can trim extra code generated by Dependency Injection?
Original Class
class HomeController
{
function __construct()
{
$this->setPhpRenderer('Module');
$this->repository = new HomeRepository($id);
$this->...
0
votes
0answers
43 views
Use Local Parameters If Global are empty?
Simplified Case with Immutable Class
final class Secret implements IFoo
{
private $header;
public function __construct(array $header = [])
{
$this->header = $header;
}
...
2
votes
1answer
125 views
Is it normal to have a SQL heavy backend for a web app's REST API?
I'm building my first PHP web app with AngularJS as the front end and utilizing Slim to create a REST-like API for the web app to interface with. I'm finding that the majority of my code I'm writing ...
2
votes
2answers
146 views
Trigger C# code from the network using PHP
I'm working on a project where I have to trigger my windows desktop app to fetch the database for new rows once a user on the internal network send new requests.
I have managed to hack this around ...
-3
votes
1answer
73 views
How booking system works
I want to do movie ticket booking and event ticket booking.
In that how to avoid duplicate booking in short cuncurrency.
I have five seats remaining in my event.
Two user comes both will see 5 ...
9
votes
9answers
1k views
Clear way to skip the first element in an index based for loop
I have a for loop where I must skip the first element in a zero-based array.
Which of these shows my intentions more clearly?
for($i=1 ; $i < count(array) ; $i++){
array[$i];
}
or
for($i=0+...
0
votes
0answers
140 views
Dependency Injection and class Inheritance
The project I am working on for about a year now was used to create a new mysqli connection to the database each time there was a Query to the database. In order to quickfix this problem at places ...
0
votes
1answer
104 views
PHP: IF statement vs. JS style expression
In situations when we need to write something like this:
if ($doStuff) {
$obj->doStuff();
}
is it acceptable to write something like this?
$doStuff && $obj->doStuff();
If not, ...
0
votes
0answers
78 views
Is this Codeigniter HMVC folder structure good practice?
The web App has four distinct user areas.
The frontend for people off the street
The user area for logged in users
A teacher zone
An Admin c-panel
I am using CodeIgniter with the HMVC extension.
...
2
votes
2answers
157 views
Am I breaking SRP when I inject Factory pattern with Repository layer?
In the context of MVC sometimes I find myself creating a Factory and injecting the factory with Repository.
While it is certainly possible to use Repository as layer inside the Factory, I wonder if ...
0
votes
1answer
50 views
Using messaging queue as async mysql writes
I read some articles about developers who takes rabbitmq and produce from PHP messages to write to mysql.
they do this to make the page speedup and not wait for mysql to return an answer.
So in my ...
0
votes
1answer
52 views
How to handle method chaining and null return for Laravel models
If I am loading a model with Model::find($id) and the id is not found it returns null.
This is fine except if I try to chain things.
Model::find($id)->loadAttributes();
Load attributes is going ...
-1
votes
1answer
90 views
Need help creating a database of map polygons
As a side project with my coworkers -- we are oil and gas geologists -- we have been creating an interactive map-based learning tool for other geologists.
We are having trouble building the database, ...
0
votes
0answers
39 views
How does the FOSS exception for MySQL connectors apply to code written in PHP or Python?
I have looked all over and can't find clear answers to the following:
If I write code in PHP or Python that uses GPL MySQL connectors for PHP or Python - which license applies to my code? That of PHP ...
0
votes
0answers
92 views
How to passing variables from php to react.js component?
For example, I have a react.js component named Question which need the props title,id,content.
<div id="main-section">
<div id="question"></div>
</div>
ReactDOM.render(
...
0
votes
1answer
65 views
Using Error Control Operators to allow try catch to handle errors
There are a few functions in php that throw errors when they fail, such as ftp_login. If I have this code.
try {
$result = ftp_login($conn_id, $ftp_user_name, 'incorrectPassword');
if (!$...
2
votes
2answers
86 views
Testing an external API that's in beta state
Our company is using an external API that is actually in beta state.
This means it's not stable at all yet, and it changes its requests/responses every week or so.
I'd like to write test to ensure ...
-3
votes
1answer
77 views
Your opinions about an idea for better php applications security?
As we all know, security is very important when making any kind of application. That's why I came up with this idea, or rather I already made it happen. Thing is I am not sure whether it is really ...
1
vote
1answer
162 views
Should I only load in the code I need if there's no performance impact for loading all of it
I have a software application. Currently at the start of each Controller it loads in only the Models it needs for that Controller. I recently tested and found that including all the models appears to ...