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

learn more… | top users | synonyms

0
votes
0answers
18 views

I am trying to implementing a stream/notification feed, but I have a dilemma

For many months now, have I tried to figure out how to implement a stream/notification feed? It can be implemented by having three tables in the database (e.g. activities, user, and user_activities) ...
-2
votes
0answers
21 views

Best approach to subscription billing [on hold]

I am creating a subscription based site from scratch. And i want to know what would be the best approach or best way to be able to accomplish subscription billing every month. So lets say a user ...
4
votes
1answer
68 views

Clean Architecture - How to go from “Database Driven” to “Independent of Database” [on hold]

I am looking for some clarity and hopefully some advice on writing clean architecture for a large system. My Companies "Web Solution" is +-10 years old, my job is to rewrite it. It is written across a ...
-2
votes
0answers
24 views

PHP Half-Hour Timezones Missings? [migrated]

In PHP I am using DateTimeZone::listIdentifiers() to get a list of timezones for user selection. This seems to be working fine, but missing from this list are the half hour timezones. Notably: ...
1
vote
1answer
63 views

Is it a good idea to modify the array keys in foreach

First let me say that i am talking about PHP, but the question is a general one. Some times i need to modify an array key for example something like: $temp = array(); foreach($arrayIWantToModify as ...
-3
votes
0answers
32 views

Querying large number of timestamps [on hold]

I have a list of timestamps in a table (there can be millions) of every time an auto-save event occurs. I want to track the amount of time people spend on a page, so every time they type a word, I ...
-1
votes
0answers
57 views

How to do simple video processing with PHP? [on hold]

I've been working with PHP for a while now, but this is the first project I've done that requires video processing. Ultimately, we want to do the following: Resize videos down so that their ...
3
votes
1answer
67 views

Designing a ticketing system where the User and Administrator have similar but different functionality

I am designing a simple ticketing system in Laravel 4. The system will simply allow a User to create a ticket, and an Administrator to answer it. The User will be able to: View a list of his ...
-3
votes
0answers
39 views

die() or try/catch when interacting with MySql database in PHP? [on hold]

A lot of tutorials and books I have been over and read have used the die() method to catch an exception when interacting with a local MySQL database For example: mysql_connect($dbhost, $dbuser, ...
-5
votes
0answers
30 views

Constantly getting PHP error when I submit a form [closed]

I am constantly getting a PHP error which is You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Change) VALUES ...
11
votes
2answers
604 views

DRY principle in good practices?

I am trying to follow the DRY principle in my programming as hard as I can. Recently I have been learning design patterns in OOP and I have ended up repeating myself quite a bunch. I have created a ...
-5
votes
0answers
28 views

PHP - Condition and Loop [closed]

i am writing a PHP script and i want to check if a number is between two other numbers like 20< x < 40 but in a very higher Range like this : ...
0
votes
1answer
39 views

How to delete active sessions and enable different users to log out from the system without any clashes [on hold]

Currently been working on some few small scale web applications but still did not understand the logic behind on how to clear off a target session? For example, imagine a small web application that ...
4
votes
1answer
52 views

Should domain model be intelligent or there must be services, which operate it?

I'm building a web-app for a licensing service. My domain models are Licenses, and they can be of two types at the moment: server and client license. They are almost same, except server license has ...
-2
votes
0answers
14 views

Help with Shell [migrated]

I was trying to create my own shell. So I have this code: <head> <title>Command Shell</title> <link rel="stylesheet" href="console.css"> </head> <body> ...
7
votes
2answers
161 views

Cross-language Test-Driven Development

The short question: How do you follow Test-Driven Development on a project that spans multiple languages? Specifically, I'm writing a web application that uses JavaScript and PHP, and I want to ...
0
votes
0answers
58 views

Execute a method upon loading a class [migrated]

I need to have a static constructor. I was always wondering why there is no support for this functionality. I need to run a function once when the class is loaded, currently the way I've seen it done ...
2
votes
2answers
169 views

matching usernames with their password

We are working on a simple login/registration form. Our login script checks to see if the username and password exist in the same row of the database. If it does exist, we bring the user to a welcome ...
2
votes
1answer
60 views

For DI, where to create dependencies (new objects) specifically within framework code?

Basic requirement I'm making a framework for learning purposes (and likely usage on personal sites). I'm using dependency injection in classes and I'm trying to design where would be a good place ...
33
votes
7answers
4k views

Is there a need to keep tests for simple (self-contained) functions?

Consider this: public function polynominal($a, $b, $c, $d) { return $a * pow($x, 3) + $b * pow($x, 2) + $c * $x + $d; } Suppose you write various tests for the above function and prove to ...
5
votes
2answers
165 views

Persisting Large/Complex Entities with the Command Pattern — Am I doing it right?

I am in the process of designing and building a large-scale inventory management software-as-a-service that will, hopefully, live a long and fruitful life. Therefore I am exerting a lot of effort ...
1
vote
2answers
170 views

Purpose of encrypted product ID/key in shopping carts

I'm a newbie for PHP ecommerce applications. For my academic activities, I need to complete a shopping cart system with basic shopping cart functions. I have studied several apps which are already ...
1
vote
2answers
59 views

Many AJAX requests to check domain availabilities [closed]

I've recently developed a website that randomly generates unique names, then checks for their .com availability. In order to do this, I call 3 AJAX requests to a php page where it randomly generates ...
1
vote
0answers
121 views

How safe is returning a password from a function? [duplicate]

Is returning sensitive data like a password from a function safe, and what attack vectors exist? (Personally, it is regarding PHP, but is a general question.) function returnDBPass(){ ...
0
votes
0answers
52 views

Best practice: Web service to issue sequence numbers

We have several disparate systems. These systems assign ORDER numbers. Basically, these are sequential numbers. They are NOT database ID numbers. These order numbers are like "A01457" or "Z4T456", ...
0
votes
0answers
27 views

Authenticate Joomla User from an External App based on Node.js, Javascript and mongoDB

I have an iOS App which currently pulls in all the data from the MongoDB using a Node JS server. Currently my API / my node server handles all the data manipulation the iOS app/Swift only displays the ...
0
votes
0answers
68 views

Using a PHP loop or MySQL table for arrays values

I have the following results page from the previous form: <?php //Get the form results (which has been converted to an associative array) from the $_POST super global $musicgenres = ...
1
vote
1answer
61 views

Should I use autoloaders in modules?

Lets say I'm running a PHP app like Magento, PrestaShop. Now these system have their own complex autoloaders to load controllers based on routes, required classes, models, etc. Most of the time as a ...
-1
votes
1answer
94 views

How do front-end developers test pages when the files they are handed are PHP views? [closed]

Someone who has a PHP project invited me to do the front-end work on his site. I don't know PHP, I've only ever worked with HTML/CSS/JS files. I cloned the project files from GitHub, and all of the ...
0
votes
0answers
29 views

MySQL schema migration table and field mapping

I have inherited a project with the following set of components: REST API, public web application and internal admin web application and MySQL dB. I am commissioned to develop updated version of the ...
0
votes
0answers
74 views

Why are scriptlets considered bad practice in JSPs when much more popular languages such as PHP seem not have any problem with them? [duplicate]

Why is doing <% if(blahblah) { //do something } %> in a JSP considered to be bad practice when noone who writes PHP seems to have any problem with doing essentially the ...
0
votes
0answers
41 views

Encrypted values (mcrypt_encrypt) in URL parameters generating different results while requesting.How to tackle the situation? [migrated]

I am using the following function to encrypt a string ($str) using a key ($key) to make a unique key. Sample Code: <?php $key = "####"; $str = "123456789"; $encrypted_key = ...
0
votes
1answer
76 views

Handle multiple data writings per second

I am planning a website with an html/javascript frontend input and a php backend. The user has to input data which will be saved in a database. Now I want to inform the other users of my site ...
1
vote
4answers
213 views

Should I Include PHP code in HTML or HTML in PHP?

What is the best practice, to write my PHP code inside my HTML code or HTML inside PHP? PHP inside HMTL: <p class="lead">Welcome to the <?= COMPANY_NAME ?> website.</p> HTML ...
2
votes
1answer
101 views

sort multidimensional array recursively - is this reasonable

In a nutshell, I needed to traverse any number of dimensions of a multidimensional array (or not) and I wanted the process to be as predictable as possible (in order to proliferate the pattern ...
1
vote
1answer
41 views

Developing an application where a chunk of the code is used by both the app the tests

I'm developing a web app in PHP where part of the code I'm developing for it will also be used in the tests. I'm not sure how to handle this. That code in question is an abstraction to communicate ...
0
votes
0answers
29 views

How does consistent hashing work in PHP memcached module?

What is the consistent-hash algorithm used by PHP's memcached module? What are its settings (that is, how many times does it add a server on the ring?) Is the consistent-hash array (continuum ring) ...
0
votes
3answers
287 views

Is it bad to store data in JSON form or should I use mySQL? [closed]

I've been building an application and the whole thing is built around a simple data storage system. Create an array. Convert it into JSON. Add <?php die() at the beginning to prevent access. ...
3
votes
1answer
25 views

Abstract/encapsulating session superglobal usage inside common accessor class

I am in the process of removing direct dependencies from an existing project. I have now come to removing the direct use of $_SESSION inside scripts. This is to make the same scripts available for an ...
3
votes
2answers
186 views

Deploy PHP application on customer server independent of the envirorment

Our company has developed a PHP(CakePHP) "Cloud" application that is running on our servers, now we have some customers that would like to use our service and make integrations to their local systems. ...
0
votes
1answer
49 views

PHP MVC concept large controller

I have custom MVC framework in PHP and my controller file has about 5000 lines. The question is, is it a big concept flaw? It is structured code with kiss method and quite maintainable. Are there ...
0
votes
2answers
76 views

Using PHP without mixing presentation logic

I'm conceptually designing a website / application and trying to come up with the correct separation of concerns. The basic technologies I'm settling on are: MySQL, PHP (Laravel), HTML/JS (jQuery). ...
0
votes
1answer
53 views

Optimizing instant notifications

Scenario To deliver instant notifications to the client, I'm sending an AJAX request to a PHP page that checks if there are new notifications: if there are, it outputs them, otherwise it sleeps for ...
1
vote
1answer
53 views

composer is self-described as inspired by npm, so why does it handle sub-dependencies differently? [closed]

As I'm sure anyone reading this knows, the default behavior for npm is to install sub-dependencies within their respective sub-dependency directories themselves (in a new node_modules directory). The ...
0
votes
1answer
25 views

Controller technique with request data in session

I am trying to find out the best possible way to save the POST data in session and making it available in different page requests. For example at website's homepage I have a Search form with ...
-2
votes
1answer
61 views

Less PHP request to REST API

I had an argument with my PHP developer today who tried to convince me that REST API has to provide all the request from PHP since a server is faster than client devices such as desktop. As I am a ...
3
votes
1answer
55 views

PHP mysql checking for relational equivalence

Suppose I have a users table and in that users table I have a role_id. In my roles table I have: users - id - role_id roles - id - name roles id | name 1 | admin 2 | normal Now ...
0
votes
1answer
53 views

Class member access on instantiation without variable

With a new feature in PHP 5.4, we can access a class member on the same line as instantiating the class. e.g. // Instead of $obj = new myClass(); $obj->myMethod(); // PHP 5.4 allows $obj = ...
2
votes
2answers
141 views

Handling insertion to database with Repository pattern

I have a design question for working with databases in object-oriented PHP. I have a table in my database called products. Then I have 2 classes for this table in my PHP project. ...
3
votes
1answer
365 views

What does comma signify in a function definition?

From PHP manual: array array_change_key_case ( array $array [, int $case = CASE_LOWER ] ) What does comma signify in a function definition?