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

learn more… | top users | synonyms

4
votes
2answers
118 views

Is trait composition an good practice?

So, I am now dealing with this relatively new codebase which uses, and sometimes feels like it abuses traits. Since I have been exposed to trait usage in a rather limited fashion, I was wondering ...
1
vote
0answers
18 views

Storing PageViews Count Data in MongoDB

I would like to ask for feedback for some programming logic concept & ideas. I am building a site where i would like to keep track on how many pageviews a page has daily. I have thought of 2 ways ...
-3
votes
0answers
11 views

Scroll page below header stub on load [on hold]

When the following page is first loaded http://www.forkosh.com/u715.html it displays a decorative (maybe too decorative:) header. But after that, when you select another image from the form, I want ...
2
votes
0answers
35 views

PHP Vertical Columns from 3 SQL Tables

I work at a high needs school in which there are several classes that plan their work through Excel spread sheets grading and tracking student progress. We have come to the conclusion that this ...
-5
votes
0answers
23 views

gmp VS bc functions in php [on hold]

Could you please tell me pros and cons of both like performance and etc? I want to know when should use gmp and when should use bc? I googled but cannot find any useful information.
-2
votes
1answer
49 views

Data exchange between two servers? [on hold]

have already working PHP server (remote) which written on Yii framework, and I was asked to build another one (local server), that will be synchronizing with the remote server whenever it updates. ...
3
votes
1answer
131 views

How do SQL transactions return immediate results?

I am using transactions to do bulk insert/updates. This is my little test loop: $now = date('Y-m-d H:i:s'); for ($i=0; $i<60; $i++) { $db->insert($cfg['ps_manufacturer'], array( ...
1
vote
3answers
96 views
+50

Inheritance when following the Repository Pattern in PHP

I am trying to build a PHP application using the Repository Pattern but I'm not sure how I should implement the save method. I have an abstract class called ItemRepository which have the following ...
0
votes
1answer
52 views

When is the best time to compute rating changes in a PHP application?

Imagine a simple PHP application where an user can post notes and the other users can upvote or downvote them. We want to implement a system where each note has a different rating (normal, good, ...
-2
votes
0answers
17 views

Saving time on mysql as data [migrated]

I want to save date and time on my mysql database and then want to show them in my webpage's comment box. But writing the following code, my database saving time as 00:00:00 at 00:00 and in the ...
0
votes
2answers
66 views

read file bytewise and find information

i am a hobby php-dev and have the following problem: i have a rar-file, whose header is damaged, therefor extracting is not fully possible. the contents are non-compressed, and can be read with eg. a ...
-3
votes
0answers
58 views

PHP OOPS: Code review [closed]

I am trying to build a web app for "Private loan provider" using PHP OOP and MySQL. I am done with DB. Folder structure : Root folder Public Index.php Js/css/templates/other front-end resources ...
0
votes
3answers
155 views

call function once again after failure, without duplicate lines?

I have what is probably an over-engineering question. I have some PHP code that logs messages to a file. We've been having a problem with the file having the wrong perms from time to time. While we're ...
-3
votes
0answers
63 views

How to use Sweet Alert Confirm [closed]

I'm trying to use sweet alert for delete, but it delete first without confirmation. I know there's something wrong with my script. The Deletion works fine, the thing is I want to prompt sweet alert ...
-2
votes
1answer
112 views

How does PayPal communicate with my website? [closed]

I have a website that will have services that need to be paid for. I was considering using PayPal as my payment merchant. What is/are the best approaches to informing my back end user account database ...
6
votes
1answer
124 views

PHP: when to use arrays, and when to use objects for mostly-data-storing code constructs?

PHP is a mixed paradigm language, allowing to use and return non-object data types, such as arrays. I pose a question to try to clarify some guidelines for selection of arrays vs objects when deciding ...
1
vote
2answers
82 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 ...
0
votes
2answers
285 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. ...
0
votes
1answer
83 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 ...
-6
votes
1answer
290 views

I am trying to implementing a stream/notification feed, but I have a dilemma [on hold]

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
54 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 ...
5
votes
1answer
116 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: ...
2
votes
2answers
130 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
1answer
80 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
708 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
57 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
175 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
185 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
66 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 ...
34
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
183 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
181 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
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
60 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
35 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
88 views

Using a PHP loop or MySQL table for arrays values [closed]

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
64 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
103 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
43 views

MySQL schema migration table and field mapping [on hold]

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
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
226 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
131 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
42 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
337 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. ...