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

learn more… | top users | synonyms

-2
votes
0answers
15 views

CSV scheduled upload with quotes and delimiter inside values [on hold]

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
31 views

unit testing a mocked class

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 ...
-4
votes
0answers
55 views

Need to explain the reasons for migrating the project from ASP to PHP [on hold]

I have a project which is built on ASP, it has three big sections or modules. Main Website (Showing content) Forum (community stuff) Portal (Previous history by map about community) Now they want ...
-1
votes
3answers
125 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
62 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 ...
-3
votes
0answers
48 views

Best Practice for reading audio file from php backend in javascript front-end [on hold]

I'm on an online music sales project and I would like to set up a web service that will play audio files. The back-end is in php and front-end php. I love the audio file will not be downloaded ...
0
votes
0answers
55 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
29 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 ...
-2
votes
1answer
24 views

Cannot figure out how Capsule Joins work [closed]

I am trying to figure out how Capsule Joins work on Select statements, but seem to be missing something. This is for my own personal knowledge and support. I created a small test script that loops ...
0
votes
2answers
94 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
66 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 ...
0
votes
1answer
23 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 (...
-3
votes
0answers
36 views

How to Requesting user permissions in connecting to a chat application

Am creating a jquery and PHP chat application which requires the other user to accept a chat request, so that one cannot chat with a person who is offline. That is, the chat can only be between two ...
0
votes
1answer
98 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 ...
1
vote
1answer
58 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
0answers
4 views

PHP tidy_repair_string [migrated]

Sample of what I'm doing. php > $str = '<p>This is a paragraph <img src="'; php > $clean = tidy_repair_string($str); php > echo $clean; <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3....
0
votes
1answer
67 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
112 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
41 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; } ...
-4
votes
0answers
54 views

When were short echo tags introduced?

While there is a lot of information about PHP's short tags around, and the distinction and overlap in configuration between <? ?> and <?= ?> before 5.4, I couldn't find when this feature ...
1
vote
1answer
116 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 ...
-1
votes
0answers
27 views

Getting desired columns from reports

I need to design an application which will extract desired data from different advertising systems. But each system could have different names for given column, and the only solution that i have ...
2
votes
2answers
139 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
61 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
982 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
129 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
100 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
61 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
145 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
36 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
42 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 ...
0
votes
1answer
66 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
54 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
64 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
83 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
76 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
160 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 ...
14
votes
10answers
2k views

Disagreement with project lead on coding standards [closed]

So I'm working on a new project along with my project lead for the past 1 year. Initially we had our own sub-projects that resided in separate git repos, I had little interaction with his code, so ...
0
votes
0answers
69 views

Comet polling eating up CPU

I'm using comet polling in Joomla (PHP) application on shared hosting. I can't use either WebSockets or Node.js, as they might not be available on client's server. I managed to maintain only one ...
0
votes
3answers
141 views

Need help choosing/creating a workflow for web development

I've been designing and programing websites for the most part of my adult life. I've always done this solo, freelancing mostly and working from a single machine. Currently, I use Dreamweaver for the ...
1
vote
2answers
99 views

Should every data field be verified to exist when parsing data from an API

I write a lot of software to interact with APIs. These APIs provide data usually in the form of an XML or JSON document. These documents are suppose to follow a spec and structure. In practice ...
2
votes
1answer
115 views

Best practice for delaying jobs

I have a system in PHP that works like a booking system. Once a booking is confirmed there are a total of 7 emails/sms that needs to be send. The times of when they need to be send are already known. ...
0
votes
1answer
78 views

External Reasons an API call might fail?

I'm currently in the process of developing my first API. This is a private api that will send information back and forth between my two sites, not one that will be open to the public. I'm working on ...
0
votes
0answers
35 views

Modular app with module JS and CSS

We are developing highly modular web application (Using Zend Framework 3). Because application is used for many purposes, we would like to enable and disable JS and CSS with every module.Every module ...
0
votes
1answer
69 views

Need my mobile application to connect my website, will this method be better than using an API?

I want my mobile app to connect to my website to get/post data from and to the database, respectively. I was looking up RESTful APIs (which I don't really understand how the file writing and ...
30
votes
10answers
9k views

What is so bad with goto when it's used for these obvious and relevant cases?

I have always known that goto is something bad, locked in a basement somewhere never to be seen for good but I ran into a code example today that makes perfect sense to use goto. I have an IP where I ...
0
votes
2answers
133 views

Restructuring web application - which design to apply?

I started to rewrite very monstrous (and old) web application. It runs on PHP 5.3, the design is completely mad - Models and Viewers, no controllers etc. I have been able to refactor the code to work ...
0
votes
0answers
44 views

Website that only loads content on modal windows (ajax)

I'm working with a client that only loves Wordpress, so I have to create a theme. The idea of my client is to have an interactive background (meaning there's no other content but the background, the ...