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

learn more… | top users | synonyms

0
votes
1answer
305 views

Tracking hours with clock in/out

I am working on a web interface that would allow the user to keep track of the amount of time people spend at their establishment. The problem: I don't know what the best way to keep track of this ...
3
votes
2answers
396 views

Roles and permissions: a good approach in defining permissions?

My application has users and administrators. The administrators split into two: super-admin and limited-admin. The super gets all permissions while the limited can be configured to inherit just the ...
1
vote
1answer
241 views

PHPDoc Comment, Class vs File

I am trying to standardise my code as much as possible, including DocComments, using PHPCS. It seems that the PEAR standards contain two sniffs that require almost exactly the same tags appear in the ...
0
votes
1answer
128 views

Best pattern to write a PHP function that checks on access and returns more then boolean?

I'm prototyping behaviour of a new application, and want to write some functions that check on access based on some variable dates. I just want to write separate functions for that, like "...
0
votes
1answer
181 views

Coding to an interface vs more generic interfaces

I have a number of classes (and interfaces) which 'code to an interface' interface File { ... } interface FileConverter { public function convert(File $file); //coding to an interface ...
2
votes
1answer
85 views

Reusing an interface or method chaining

I am learning about coding to an interface in OOP programming. I understand you should code to an interface so you can 'swap out' functionality. However, I have a situation where I feel I can reuse ...
1
vote
0answers
115 views

Are facilities that generate HTML for you, considered harmful? [closed]

I will approach this from two directions (+ raw HTML itself being de-facto third) Proprietary HTML-generating code Code generating facilities provided by a popular library Proprietary HTML-...
1
vote
1answer
247 views

Synchronize database with external API

I currently own a website where players can look-up their statistics of a game. When someone that is not in my database yet requests their statistics, I am calling the API with a PHP cURL request and ...
1
vote
0answers
61 views

Storing reference to a model obtained using DataMapper to be able to call save on it

When using the DataMapper pattern, which involves modeling classes containing business logic and knowing absolutely nothing about persistence, caching,... I usually want the models to represent real-...
1
vote
0answers
49 views

Recursive(?) algorithm design help

I have a requirement to allow my end users to input formula much like a spreadsheet. I have an array like this: $table = array( 1=>array( "id"=>1, "Name"=>"...
0
votes
2answers
335 views

Are hooks really subsumed by Slim Framework middleware?

I've been using the Slim Framework (v2) for a little while now to develop my user management system. They recently released Slim 3, and according to the upgrade guide, Slim v3 no longer has the ...
2
votes
0answers
158 views

Why do some top projects require write permission on code itself? [closed]

Well this could be a very wide question as every project have different philosophies. But meanwhile question is that We have lot of projects like Yii, Drupal, Apigility which requires full write ...
1
vote
1answer
104 views

Access container object from within an item

Generally I have 3 classes, a container that holds an array of items and a special object that is another property of the container class. What I need to do is access the special object from an item ...
2
votes
0answers
50 views

Where to output from large CLI app [closed]

I've built a reasonably sized CLI app with everything split across different classes and namespaces in a logical way. However many components need to render output from within themselves. Which seems ...
3
votes
2answers
143 views

How to accomplish a task of evaluating editable variables and formulas, using PHP?

Task as defined: User needs to be able to define their own variables and formulas to operate on those variables, to get output based on their inputs. Since formulas and variables and their inputs ...
2
votes
0answers
69 views

Standard for order of tags in PHP DocBlocks?

Based on the tags listed from this "standard", is there an order of the tags that people typically follow? Even if it's not something that has been entirely accepted, but something proposed? I am ...
0
votes
1answer
137 views

PHP MySQL unique user data [closed]

I'm trying to create a php website that users log into and they can submit data to a MySQL database. How do I make it so the users can only see data they've submitted and not everyone else's data? ...
0
votes
0answers
128 views

Correct way of running methods from frontend in an OOP framework

If I have a link to change language of my website, where should that link lead in order to execute a PHP command, specifically in Codeigniter framework? I am interested in the most recommended, DRY ...
0
votes
0answers
108 views

Test for PHP Errors using Browser Emulator (Mink)

I want to know the most robust way of checking for PHP error messages when running automated tests that interact with a PHP application via a browser emulator. The reason is: I use Behat, Mink and ...
4
votes
2answers
281 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
1answer
179 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 ...
2
votes
0answers
167 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 ...
3
votes
1answer
168 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( '...
3
votes
5answers
367 views

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
63 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, ...
0
votes
2answers
160 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 ...
0
votes
3answers
207 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 ...
14
votes
1answer
3k 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
669 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 ...
-1
votes
2answers
351 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
181 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 ...
2
votes
2answers
151 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 ...
6
votes
1answer
539 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
3answers
345 views

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

Some times I need to modify an array key for example something like: $temp = array(); foreach($arrayIWantToModify as $key => $value) { if($value % 2) == 0) { $temp['odd_' . $key] = $...
5
votes
2answers
317 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
907 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
78 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 ...
9
votes
3answers
287 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 ...
2
votes
2answers
640 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
139 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 ...
35
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
377 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 up-...
2
votes
2answers
211 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(){ $pass="...
0
votes
0answers
199 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", etc....
2
votes
0answers
223 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 ...
1
vote
1answer
133 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
149 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
78 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
90 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 ...