Questions about PHP, a widely-used general-purpose scripting language that is especially suited for Web development.
0
votes
0answers
14 views
PHP USB serial port call from Windows to Linux
I have a piece of simple code that works on a Windows - WAMP environment, e.g.
<?php
`mode com3: BAUD=38400 PARITY=N data=8 stop=1 xon=off`;
file_put_contents(com3, ...
-2
votes
0answers
9 views
get row number on macting perticuler value using PHPexcel lib [on hold]
phpexcel lib
@version 1.8.0, 2014-03-02
$objPHPExcel->setActiveSheetIndex(0)->getrow()
i want row number on matching particular cell value
something like ..
get_row_number("match_value")
0
votes
2answers
61 views
Alternatives to cron jobs or other ways of improving scheduled task performance
I'm working on a social networking website where users gain ratings after specific actions taken and proper conditions are met on the tables. The ratings are calculated depending on 'total hours ...
-2
votes
0answers
14 views
How do I remove the dot using isDot() using RecursiveDirectoryIterator? [migrated]
I have this simple below code to help me get the contents of all files and sub folder. I took this code from the PHP cook book. it says that I can use the isDot() but it doesn't explain how to ..
I ...
-4
votes
0answers
21 views
Should contentType be in my ajax? If yes how to fix it [on hold]
I been trying to figure this one out but i don't seem to find the error but in my script
My script
$('#Bshift').click(function(){
var isValid=false;
isValid = validateForm();
if(isValid)
{
var ...
0
votes
2answers
242 views
How are complex programs made? [duplicate]
I know a few languages, and can program in them. How do multiple languages blend together in a single program? For ex. https://github.com/facebook/watchman. This uses C, PHP, Python, Javascript, etc. ...
-6
votes
0answers
26 views
How to Display other user details through where clause = Session variable [on hold]
I want to display the user's Firstname, Lastname, Birthday and Gender. The session works fine but i dont know the Echo code for this, Thanks!!
$sql = "SELECT lastname FROM user ...
0
votes
1answer
81 views
What is the problem will happen if I create auto generate ID without using mysql auto increase of mysql table by my self?
I would like to ask you a question about MySQL AUTO_INCREMENT.
I already created my own function to generate AUTO_INCREMENT when the user inserts any data input a table in MySQL. This function works ...
-5
votes
2answers
228 views
+50
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
2answers
42 views
How can I keep data integrity across multiple services in a transaction-like fashion with PHP? [duplicate]
I find the concept of transactions really useful when working with databases because obviously it allows you to rollback changes if one step of a modification goes awry.
Is there some way I can ...
-2
votes
0answers
38 views
Best approach to subscription billing [closed]
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 ...
5
votes
1answer
91 views
Clean Architecture - How to go from “Database Driven” to “Independent of Database” [closed]
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: ...
3
votes
2answers
122 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
37 views
Querying large number of timestamps [closed]
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
62 views
How to do simple video processing with PHP? [closed]
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
75 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 ...
11
votes
2answers
663 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 ...
4
votes
1answer
53 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
167 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
177 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
62 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
172 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
172 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
53 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
30 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
74 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
63 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
96 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
34 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
78 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
218 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
105 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
297 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
189 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
52 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
77 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 ...